Skip to content

Instantly share code, notes, and snippets.

@kyletolle
Created July 28, 2013 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyletolle/6097061 to your computer and use it in GitHub Desktop.
Save kyletolle/6097061 to your computer and use it in GitHub Desktop.
Automatically strip trailing whitespace from files within files in VIM.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Automatically strip trailing whitespace from lines within files
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd BufWinEnter,BufRead,InsertLeave,BufEnter * call RemoveTrailingWhitespace()
function! RemoveTrailingWhitespace()
silent! execute '%s/\s\+$//g'
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment