Tip 757 Printable Monobook Previous Next

created July 2, 2004 · complexity basic · author panshdw · version 6.0

function! NumberNo()
  set nonumber
  map <F12> :call NumberYes()<CR>

function! NumberYes()
  set number
  map <F12> :call NumberNo()<CR>
map <F12> :call NumberNo()<CR>

Comments[edit | edit source]

This also works:

:map <F12> :set number!<CR>
"" for insert mode
:imap <F12> <c-o>:set number!<CR>

Another alternative is:

:map <F12> :let &number=1-&number<CR>

I do this -- which inverts the 'number' option for every window:

func! s:NumToggle()
  let s:current_winnr = winnr()
  windo set invnumber
  exec s:current_winnr."winc w"
map <F12> :call <SID>NumToggle()<CR>

You can also do this:

noremap <silent> <F12> :if &number \| set nonumber \| else \| set number \| endif<CR>

Yes, but it's faster to just do:

noremap <silent> <F12> :set number!<CR>

Community content is available under CC-BY-SA unless otherwise noted.