aboutsummaryrefslogtreecommitdiff
path: root/vim/vimrc
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2014-11-03 00:03:49 +1300
committerTom Ryder <tom@sanctum.geek.nz>2014-11-03 00:03:49 +1300
commitd41ab635ac3c47999f309763f48e217db695e848 (patch)
tree205362dd138969fe613a0cd6e731cb0b170862a5 /vim/vimrc
parentMake explicit local vars (diff)
downloaddotfiles-d41ab635ac3c47999f309763f48e217db695e848.tar.gz
dotfiles-d41ab635ac3c47999f309763f48e217db695e848.zip
Make function of whitespace stripper
Diffstat (limited to 'vim/vimrc')
-rw-r--r--vim/vimrc11
1 files changed, 9 insertions, 2 deletions
diff --git a/vim/vimrc b/vim/vimrc
index bc74c35c..a66934ef 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -170,8 +170,15 @@ if has('eval')
endif
" Strip trailing whitespace with \x
-nnoremap <silent> <leader>x
- \ :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
+if has('eval')
+ function! StripTrailingWhitespace()
+ let l:search = @/
+ %s/\s\+$//e
+ let @/ = l:search
+ nohlsearch
+ endfunction
+ nnoremap <silent> <leader>x :<C-U>call StripTrailingWhitespace()<CR>
+endif
" Keep plenty of command and search history, because disk space is cheap
set history=2000