Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Newline at End of File Support

adamlehenbauer edited this pageJul 3, 2016 ·10 revisions

This property has already been added to the EditorConfig specification asinsert_final_newline. This wiki page is only for archive purposes.


Editor Support for Newline Insertion at End of File

Option for Inserting Newlines at End of File

Aninsert_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

Naming ideas

The options would betrue andfalse 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

Support in Editors

Vim

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 enablingbinary file editing and disabling theendofline option. We may be able to usethis method of disabling newline insertion on write for the Vim plugin. One notable quirk with this method is that settingbinary 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.

Emacs

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 therequire-final-newline option tonil.

Gedit

Default behavior:

  • doesn't show the last newline at the end of the file
  • automatically adds a newline when saving files

Thisbehavior cannot be changed in Gedit currently. Gedit will not be able to support this option.

Notepad++

Default behavior:

  • shows the last newline at the end of the file
  • does not automatically add a newline when saving files

jEdit

Default behavior:

  • doesn't show the last newline at the end of the file if the file hada trailing newline when it was opened
  • automatically adds a newline when saving for new files only(preserves missing newlines in existing files)

Visual Studio

Default behavior:

  • shows the last newline at the end of the file
  • does not automatically add a newline when saving

Geany

Default behavior:

  • Shows the last newline at the end of the file
  • adds a newline if "Ensure newline at file end" is checked

Sublime Text 2

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 theensure_newline_at_eof_on_save option totrue.

The wiki is disabled from public edits due to spams. If you would like to request a change in wiki, please open anew discussion.

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp