tags:

views:

54

answers:

2

Hi all, i have mapped my caps lock key to ctrl with the following command under linux:
setxkbmap -option ctrl:nocaps I really like this mapping and want to keep it, but I also would like to map the caps lock key to Escape when I am inside vim. But when I try to map it with :map <C> <Esc> or similar it does not seem to work, presumably because the ctrl key is special and needs a second key to to trigger an key event.

Is there any way I can achieve the above?

+2  A: 

No. The control, shift and alt keys are handled differently at the hardware and OS levels - they do not generate keycodes but add modifiers to the keycodes generated by other keys. This means that they cannot be mapped within Vim.

Dave Kirby
+3  A: 

Dave is right, you can't. However, there are lots of alternatives to remap the escape key. I personaly use ` which is close (on my keyboard) to the capslock key :-) (as ' is pretty useless , you can remap ' to `)

noremap ' `
noremap ` <Esc>
mb14
It is true that there are lots of alternatives. Myself I have the Tab key mapped to Escape, which means I can do <C-i> instead of hitting Escape because in Vim Control + i is equivalent to the Tab key. This is quite an ok solution for me personally..