From 1864c0430f4fb4d604cff70137949759d21e4471 Mon Sep 17 00:00:00 2001 From: Tony Duckles Date: Sun, 1 Sep 2013 14:57:36 -0500 Subject: [PATCH] .vimrc: Enhanced strip-trailing-whitespace --- .vim/bundle/whitespace/plugin/whitespace.vim | 9 +++++++++ .vimrc | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .vim/bundle/whitespace/plugin/whitespace.vim diff --git a/.vim/bundle/whitespace/plugin/whitespace.vim b/.vim/bundle/whitespace/plugin/whitespace.vim new file mode 100644 index 0000000..bd0bfe2 --- /dev/null +++ b/.vim/bundle/whitespace/plugin/whitespace.vim @@ -0,0 +1,9 @@ +" thanks to http://vimcasts.org/e/4 +function! whitespace#strip_trailing() + let previous_search=@/ + let previous_cursor_line=line('.') + let previous_cursor_column=col('.') + %s/\s\+$//e + let @/=previous_search + call cursor(previous_cursor_line, previous_cursor_column) +endfunction diff --git a/.vimrc b/.vimrc index f4aeacb..635dadc 100644 --- a/.vimrc +++ b/.vimrc @@ -257,7 +257,7 @@ nmap l mQviwu`Q nmap U mQgewvU`Q nmap L mQgewvu`Q " strip all trailing whitespace in file -nmap s :%s/\s\+$// +nmap s :call whitespace#strip_trailing() " toggle spell-check nmap sp :setlocal spell! spelllang=en_us spell? " set text wrapping toggles -- 2.45.2