diff --git a/plugin/trailing-whitespace.vim b/plugin/trailing-whitespace.vim index c860148..5688ef4 100644 --- a/plugin/trailing-whitespace.vim +++ b/plugin/trailing-whitespace.vim @@ -6,6 +6,12 @@ autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ autocmd InsertLeave * match ExtraWhitespace /\s\+$/ autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@,substitute/\s\+$// | let @/ = savesearch | unlet savesearch +function! s:FixWhitespace(line1,line2) + let l:save_cursor = getpos(".") + silent! execute ':' . a:line1 . ',' . a:line2 . 's/\s\+$//' + call setpos('.', l:save_cursor) +endfunction + +" Run :FixWhitespace to remove end of line white space. +command! -range=% FixWhitespace call FixWhitespace(,)