From 89a457addf420123c6231c11d02edad96db7fb88 Mon Sep 17 00:00:00 2001 From: Scott Bronson Date: Wed, 15 Sep 2010 17:12:15 -0700 Subject: [PATCH] Move FixWhitespace into a function. Closes #1 Help from http://github.com/Superflo/vim-files/blob/master/.vimrc#L277 --- plugin/trailing-whitespace.vim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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(,)