Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).
created December 31, 2010 · complexity basic · author Joliss · version 7.0
By default, Vim adds a newline after the last line of each file. That's great for new files, but when you edit other people's files and they don't have newlines at the end, the diff gets cluttered with an extra chunk like this, because Vim "helpfully" added a newline:
- } \ No newline at end of file + }
To stop this from happening, add this to your .vimrc:
set binary
Caveats:
- This will break your line-endings on Windows.
- Options textwidth, wrapmargin, modeline and expandtab are reset by :set binary, so make sure that "set binary" comes before setting any of these options.
Always remove newlines at EOF
If you want to always strip newlines from files, you can try this:[1]
au BufWritePre * :set binary | set noeol au BufWritePost * :set nobinary | set eol