tags:

views:

993

answers:

3

I've added:

set number
nnoremap  <F2>:set nonumber!

to my vimrc file. Basically what it's supposed to do is let me press to toggle line numbering but it's not working. What have I done wrong?

Thanks in advance :)

+5  A: 

In your .vimrc, try :

set number
nnoremap <F2> :set nonumber!<CR>

This will toggle line numbering while you press F2.

Taurus Olson
+4  A: 

This is what I use (with a different key binding):

nmap <f2> :set number! number?<cr>

The "number!" toggles the setting and "number?" reports the state.

Jeremy Cantrell
+1  A: 

This is one method:

map <silent> <F2> :if &number <Bar>
    \set nonumber <Bar>
     \else <Bar>
    \set number <Bar>
     \endif<cr>

(this one is nice 'cause I usually put foldcolumn in there as well)

This is another:

map <silent> <F2> :set invnumber<cr>

(direct method)

ldigas