public
Last active

Toggle {number,relativenumber,off}

  • Download Gist
ToggleNumber.vim
VimL
1 2 3 4 5 6 7 8
nn <silent> <leader>vn :call ToggleNumber()<CR>
fun! ToggleNumber() "{{{
if exists('+relativenumber')
:exec &nu==&rnu? "setl nu!" : "setl rnu!"
else
setl nu!
endif
endf "}}}
for mapmode in ["n", "x", "o"]
    exe mapmode . "noremap <expr> <Leader>0 ToggleNumberDisplay()"
endfor

function! ToggleNumberDisplay()
    if exists('+relativenumber')
        exe "setl" &l:nu ? "rnu" : &l:rnu ? "nornu" : "nu"
    else
        setl nu!
    endif
endfunction

@SethMilliken, thanks. I merged you suggestion with sehe solution

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.