How to make your editor add empty line at the end of file
PHP recommends adding empty line at the end of php files. But now other people find it great, especailly when comparing difference in github.
To make your editor add empty line in the end of file:
Ensure your IDE/editor has the relevant setting set:
- IntelliJ: navigate to Settings > Editor > General and
- check Ensure line feed at file end on Save
- set Strip trailing spaces on Save to Modified Lines
- VSC: navigate to Preferences > Settings and
- search for “newline” and check the following
- Files: Insert Final Newline
- Files: Trim Final Newlines
- search for “whitespace” and check Trim Trailing Whitespace
- search for “newline” and check the following
- Sublime Text: navigate to Preferences > Settings > Default find and set the following to
true
:trim_trailing_white_space_on_save
ensure_newline_at_eof_on_save
- … or use Single Trailing Newline package to ensure one and only one newline at the end of file
Other IDEs may have a setting similar to any of the above.