" Cycle between displaying absolute line numbers, relative numbers, or
" no line numbers
"
" CTRL-N by default moves the cursor down by one line.
" Personally, I never use it that way as there are already four other
" ways to do that
if exists('+relativenumber')
nnoremap <expr> <C-N> CycleLNum()
xnoremap <expr> <C-N> CycleLNum()
onoremap <expr> <C-N> CycleLNum()
" this function cycles between normal, relative, and no line
numbering
function! CycleLNum()
if &l:rnu
setlocal nonu nornu
elseif &l:nu
setlocal nu rnu
else
setlocal nu
endif
" sometimes (op-pending mode) the redraw doesn't happen
" automatically - so I'll force it to happen
redraw
" return nothing; this is important to op-pending mode
return ""
endfunc
endif
from http://unnovative.net/