Skip to content

Instantly share code, notes, and snippets.

@rgo
Forked from fxn/.vimrc
Created September 22, 2016 10:46
Show Gist options
  • Save rgo/21687935a9bda2827e227e92855a3c7a to your computer and use it in GitHub Desktop.
Save rgo/21687935a9bda2827e227e92855a3c7a to your computer and use it in GitHub Desktop.
function! s:EnableRelativeNumber()
set nonumber
set relativenumber
endfunction
function! s:DisableRelativeNumber()
set norelativenumber
set number
endfunction
function! s:ToggleRelativeNumber()
if &relativenumber == 1
call <SID>DisableRelativeNumber()
else
call <SID>EnableRelativeNumber()
endif
endfunction
autocmd InsertEnter * :call <SID>DisableRelativeNumber()
autocmd InsertLeave * :call <SID>EnableRelativeNumber()
nmap <silent> <leader>nl :call <SID>ToggleRelativeNumber()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment