Skip to content

Instantly share code, notes, and snippets.

@juanpabloaj
Created September 24, 2011 20:15
Show Gist options
  • Save juanpabloaj/1239808 to your computer and use it in GitHub Desktop.
Save juanpabloaj/1239808 to your computer and use it in GitHub Desktop.
Toggle {number,relativenumber,off}
nn <silent> <leader>vn :call ToggleNumber()<CR>
fun! ToggleNumber() "{{{
if exists('+relativenumber')
:exec &nu==&rnu? "setl nu!" : "setl rnu!"
else
setl nu!
endif
endf "}}}
@SethMilliken
Copy link

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

@juanpabloaj
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment