Weekly Emacs tip #5: Make sure files always end with a newline
Several lint tools and Git pre-commit hooks require that files end with a newline character. This is easy to achieve in Emacs through the require-final-newline variable. By default this variable is nil, but when set to t Emacs will automatically add a final newline (if it isn’t already there) when saving a file.
I have added this to the :custom section of my (use-package emacs) block with general customizations:
(use-package emacs :custom ;; Always insert at final newline character (if not present yet) ;; when saving a file. (require-final-newline t) )
Alternatively, if you don’t use use-package the following should work:
(setq require-final-newline t)
No Comments