On Monday, March 12, 2012 1:30:29 AM UTC-5, Hanfei Shen wrote:
> Hi,
>
> I want to set normalnumber in normal mode and insert mode, relativenumber in
> visual mode. Is there a way to do that?
>
> Thanks!
>
> Hanfei
You could potentially map all the visual-mode entry commands to first set
relativenumber and then enter the desired visual mode, but this is a bit of a
hack. I personally just use the following which lets me cycle between line
numbering styles in any mode (well, not in insert mode, but that is easy enough
to add):
if exists('+relativenumber')
nnoremap <expr> <C-Space> CycleLNum()
xnoremap <expr> <C-Space> CycleLNum()
onoremap <expr> <C-Space> CycleLNum()
" function to cycle between normal, relative, and no line numbering
func! CycleLNum()
if &l:rnu
setlocal nu
elseif &l:nu
setlocal nonu
else
setlocal rnu
endif
" sometimes (like in op-pending mode) the redraw doesn't happen
" automatically
redraw
" do nothing, even in op-pending mode
return ""
endfunc
endif
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php