aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vim/config/whitespace.vim9
1 files changed, 5 insertions, 4 deletions
diff --git a/vim/config/whitespace.vim b/vim/config/whitespace.vim
index 2202f47b..119d2c48 100644
--- a/vim/config/whitespace.vim
+++ b/vim/config/whitespace.vim
@@ -5,10 +5,11 @@ set nojoinspaces
" Strip trailing whitespace with \x
if has('eval')
function! StripTrailingWhitespace()
- let l:search = @/
- %substitute/\s\+$//e
- let @/ = l:search
- nohlsearch
+ let l:li = 1
+ for l:line in getline(1,'$')
+ call setline(l:li, substitute(l:line, '\m\C\s\+$', '', 'g'))
+ let l:li = l:li + 1
+ endfor
endfunction
nnoremap <silent> <leader>x :<C-U>call StripTrailingWhitespace()<CR>
endif