mirror of
https://github.com/bronson/vim-trailing-whitespace.git
synced 2025-11-08 11:33:54 -05:00
Move FixWhitespace into a function. Closes #1
Help from http://github.com/Superflo/vim-files/blob/master/.vimrc#L277
This commit is contained in:
@@ -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>)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user