How can I configure Android studio to add new line at end of file? How can I configure Android studio to add new line at end of file? git git

How can I configure Android studio to add new line at end of file?


Yes, you can configure Android Studio to automatically add a new line at the end of a file.

File | Settings... menu, then Editor under IDE Settings, then check the Ensure line feed at file end on Save option box.

This will only take effect on freshly edited files after the setting has been enabled.


UPDATE

On newer versions of Android Studio, the preference location has changed to

File > Preferences > Editor > General > Ensure line feed at file end on Save


In the latest Android Studio (2.3.3), the setting has moved.

Android Studio -> Preferences -> Editor -> General -> Ensure line feed at file end on Save


The previous changes for Android Studio (53630 - 52407 and 54132 - 52407: should add a newline at the end of autogenerated xml files) seem to suggest there is no global setting to add a newline for every file.

It may have changed depending on the Android Studio you are using (eclipse-based or the more recent IntellJ IDEA-based), but you can check the formatters associated with the different types of files: they usually have that option "add newline at the end of a (certain type of) file".