Skip to content

Instantly share code, notes, and snippets.

@fxn
Created September 22, 2016 10:42
Show Gist options
  • Save fxn/1ee8c6e9e1e5a53674e204d5cfe6336c to your computer and use it in GitHub Desktop.
Save fxn/1ee8c6e9e1e5a53674e204d5cfe6336c 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