Switch to hybrid relative number in vim

This commit is contained in:
lhark 2017-10-19 01:09:25 -04:00
parent 7f88c72e3b
commit b1cc6e8075

10
vimrc
View file

@ -282,6 +282,7 @@ set textwidth=0
"[Settings of line numbers]" "[Settings of line numbers]"
set number set number
set numberwidth=2 set numberwidth=2
set relativenumber
"[Don't show current position]" "[Don't show current position]"
set ruler set ruler
"[For regular expressions turn magic on]" "[For regular expressions turn magic on]"
@ -452,3 +453,12 @@ function! ShowModeInStatusLine()
endif endif
return g:showMode return g:showMode
endfunction endfunction
"[Toggle relativenumber between normal & insert mode]"
"[Credit: https://jeffkreeftmeijer.com/vim-number/#relative-line-numbers ]"
if has("autocmd")
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END
endif