-
Notifications
You must be signed in to change notification settings - Fork 103
Newline at End of File Support
This property has already been added to the EditorConfig specification as insert_final_newline
. This wiki page is only for archive purposes.
An insert_final_newline
option (or similarly named option) will control whether a newline is automatically inserted at the end of a file on save (when a newline is missing).
Understood values for this option will be:
-
true
: a newline will be inserted at the end of the file automatically -
false
: no newline will be inserted at the end of the file automatically
The options would be true
and false
and would have the same behavior as described above for all of the below option names.
Names this option might have:
- insert_final_newline
- require_final_newline
- insert_newline_at_end_of_file
Default behavior:
- doesn't show the last newline at the end of the file
- automatically adds a newline when saving files
Automatic newline insertion can be disabled by enabling binary file editing and disabling the endofline option. We may be able to use this method of disabling newline insertion on write for the Vim plugin. One notable quirk with this method is that setting binary
forces LF line endings so this method cannot be used for files with CRLF line endings which would probably be the most common case for this option. This vim tip on preserving missing newlines at end of file may help resolve this issue.
Default behavior:
- shows the last newline at the end of the file
- automatically adds a newline when saving files
Automatic newline insertion can be disabled by setting the require-final-newline option to nil
.
Default behavior:
- doesn't show the last newline at the end of the file
- automatically adds a newline when saving files
This behavior cannot be changed in Gedit currently. Gedit will not be able to support this option.
Default behavior:
- shows the last newline at the end of the file
- does not automatically add a newline when saving files
Default behavior:
- doesn't show the last newline at the end of the file if the file had a trailing newline when it was opened
- automatically adds a newline when saving for new files only (preserves missing newlines in existing files)
Default behavior:
- shows the last newline at the end of the file
- does not automatically add a newline when saving
Default behavior:
- Shows the last newline at the end of the file
- adds a newline if "Ensure newline at file end" is checked
Default behavior:
- Shows the last newline at the end of the file
- Does not add a newline when saving files by default
This behavior can be changed by setting the ensure_newline_at_eof_on_save
option to true
.