diff --git a/vim/vimrc b/vim/vimrc index c7e9fc7..5435c9d 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -72,3 +72,15 @@ set shiftround " always indent/outdent to the nearest tabstop set expandtab " use spaces instead of tabs set smarttab " use tabs at the start of a line, spaces elsewhere set nowrap " don't wrap text + +match ErrorMsg '\s\+$' " mark trailing whitespace + +" Removes trailing spaces +function! TrimWhiteSpace() + %s/\s\+$//e + endfunction + +autocmd FileWritePre * :call TrimWhiteSpace() +autocmd FileAppendPre * :call TrimWhiteSpace() +autocmd FilterWritePre * :call TrimWhiteSpace() +autocmd BufWritePre * :call TrimWhiteSpace()