Toggle line numbering mode

2 Points

sbicknel sbicknel

10 years ago

This function cycles through numbering off, normal, and relative numbering.

" toggle number mode
function! ToggleNumberMode()
    if &relativenumber == 1
	set norelativenumber
        set number
	echo "normal numbering"
    elseif &number == 1
	set nonumber
	echo "numbering off"
    else
	set relativenumber
	echo "relative numbering"
    endif
    return
endfunc
nnoremap <f6> :call ToggleNumberMode()<cr>
vnoremap <f6> :call ToggleNumberMode()<cr>
inoremap <f6> <c-o>:call ToggleNumberMode()<cr>