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.
- textwidth, wrapmargin, modeline and expandtab are reset by "set binary", so make sure that "set binary" comes before any of those.
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