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 " }