From 2a75aeac75a67526bada9cae0a698967146357fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 3 Aug 2012 15:49:34 +0200 Subject: vimrc: add Preserver function map _$ to remove all trailing spaces map _= to reindent the whole file --- vimrc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vimrc b/vimrc index 55b9efe..8e7216a 100644 --- a/vimrc +++ b/vimrc @@ -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") +nmap _= :call Preserve("normal gg=G") -- cgit v1.1-2-g2b99