From 4e2cc582e1dd309d6f5ff14f2dc23cfa32aebd72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Sun, 15 Sep 2013 21:04:27 +0200 Subject: [PATCH] Vim now automatically removes trailing whitespace. --- vim/vimrc | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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()