I use Android Studio and when I commit to a repo on GitHub and view git diff I see a red marker at end of line for few files with a warning 'No newline at end of file'. How can I configure Android Studio to ensure that it does add a newline at file of file for every file. Thank you.
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
Android Studio > Preferences > ...
–
Shoran Ensure every saved file ends with a line break
. Also, for it to work properly, you have to uncheck Keep trailing spaces on caret line
. –
Prognosis 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
File
-> Settings
-> Editor
-> General
-> Ensure line feed at file end on Save
–
Mobilize On Android Studio Bumblbee open Preferences -> General -> enable option "Ensure every saved file ends with a line break"
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".
© 2022 - 2024 — McMap. All rights reserved.
File → Settings → ..
. – Enchantress