You could also run that :substitute on :w and never have to worry about trailing whitespace ever again :) autocmd BufWritePre * :%s/\s\+$//e
Great tip! Just remember if you place a `autocmd` in your vimrc to place it in a `augroup` and run `autocmd!`. Otherwise vim will create multiple `autocmd`s for this each time vimrc is sourced. If I'm correct something like the following will avoid that. E.g. augroup trailing_whitespace autocmd! autocmd BufWritePre * :%s/\s\+$//e augroup END Also for non-vim users, the git book has an incredible section on configuring git to help with whitespace issues. http://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#Formatting-and-Whitespace - Daniel
Attachment:
signature.asc
Description: Digital signature