From 8780a794312cc80ab6ea23cb3e568d45a4a5fd1e Mon Sep 17 00:00:00 2001 From: Guillaume DOTT Date: Fri, 14 Dec 2012 15:22:26 +0100 Subject: [PATCH] vim: use relativenumber and some autocmd to switch between the two --- vim/vimrc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index 0fc25ff..29e38b3 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -36,7 +36,7 @@ syntax enable set background=dark colorscheme desert -set number +set relativenumber set showmode set expandtab set shiftwidth=4 @@ -122,6 +122,8 @@ map :GundoToggle map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . " Rot13 map ggVGg? + +nnoremap r :call NumberToggle() " } " PLUGINS @@ -201,6 +203,15 @@ function! ToggleYesNo() exec "normal! \"_ciw\=w\\b" endif endfunc + +" NumberToggle toggles between relative and absolute line numbers +function! NumberToggle() + if(&relativenumber == 1) + set number + else + set relativenumber + endif +endfunc " } " MISC @@ -208,4 +219,9 @@ endfunc " Every spaces/tabs at the end of line will be highlighted. au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\s\+$', -1) " autocmd BufWrite * silent! %s/[\r \t]\+$// + +autocmd WinLeave * set number +autocmd WinEnter * set relativenumber +autocmd InsertEnter * set number +autocmd InsertLeave * set relativenumber " }