diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-08-03 15:49:34 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-08-03 15:49:34 +0200 |
commit | 2a75aeac75a67526bada9cae0a698967146357fa (patch) | |
tree | b20350f1bbdf93d3d732b2cf31ee501762afcf0c | |
parent | 1dec590693a752590d216c90eafe312fe6a3bb09 (diff) | |
download | vim-2a75aeac75a67526bada9cae0a698967146357fa.zip vim-2a75aeac75a67526bada9cae0a698967146357fa.tar.gz |
vimrc: add Preserver function
map _$ to remove all trailing spaces
map _= to reindent the whole file
-rw-r--r-- | vimrc | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -94,3 +94,16 @@ if has("autocmd") endif " has("autocmd") +function! Preserve(command) + " Preparation: save last search, and cursor position. + let _s=@/ + let l = line(".") + let c = col(".") + " Do the business: + execute a:command + " Clean up: restore previous search history, and cursor position + let @/=_s + call cursor(l, c) + endfunction +nmap _$ :call Preserve("%s/\\s\\+$//e")<CR> +nmap _= :call Preserve("normal gg=G")<CR> |