Move FixWhitespace into a function. Closes #1

Help from http://github.com/Superflo/vim-files/blob/master/.vimrc#L277
This commit is contained in:
Scott Bronson
2010-09-15 17:12:15 -07:00
parent c5f1e9298f
commit 89a457addf

View File

@@ -6,6 +6,12 @@ autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/ autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/ autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
" Run :FixWhitespace to remove end of line white space. function! s:FixWhitespace(line1,line2)
command! -range=% FixWhitespace silent! let savesearch = @/ | keepjumps <line1>,<line2>substitute/\s\+$// | let @/ = savesearch | unlet savesearch 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 <SID>FixWhitespace(<line1>,<line2>)