Vim logo vim online Vim Book Ad

 Tip #342: Remap <ESC>

 tip karma   Rating 9/11, Viewed by 555 

created:   October 11, 2002 13:54      complexity:   intermediate
author:   mrts      as of Vim:   6.0

Tired of hunting down <ESC> at upper-left of your keyboard while using a keyboard with useless Windows keys?

Well, remap them -- use xmodmap. I'm using Debian and my xmodmap config file is in /etc/X11/xinit/xmodmap, ymmv.
You may have to use xmodmap directly (from ~/.xinitrc  in *BSD or whatever).

Anyway, here's my xmodmap:
[ .. other irrelevant mappings skipped ... ]
keycode 115 = braceleft
keycode 116 = Escape
keycode 117 = braceright

Btw, the keys are:
    * 115 - Windows key, between the left-hand Ctrl and Alt keys
    * 116 - Windows key, to the right of the AltGr key
    * 117 - Menu key, to the left of the right-hand Ctrl key

Valid for all environments with X, on *BSD as well as on Linux.
You get the same mappings under ordinary console by modifying the console keymap file (pretty self-explanatory), in my case it's
/usr/share/keymaps/i386/qwerty/et.kmap.gz.

I'm using mapping braces to winkeys because of my Estonian keyboard.

 rate this tip  Life Changing Helpful Unfulfilling 

<<switch color schemes | Faster loading of large files >>

Additional Notes

Anonymous, October 12, 2002 11:58
I have remapped Caps Lock to Esc. Who use Caps Lock any way?
Anonymous, October 12, 2002 15:00
I think users with german, slavic (and probably some other) keyboards will have better things to do with the windows key - because we need additional keys for "umlauts" like ö etc. or other language-specific letters, some of the important signs, namely {[]}\ are the "third-function" of number keys 7 and above. You have to type those with the right hand, while simultaneously pressing "Alt Ctr" located right of the spacebar which at least I never learned to do properly, you can't do that without changing the position of the hand, and I keep hitting the wrong key. I've been raging about this stupid mapping for a long time without it ever occurring to me that there's a free key you could map to Alt Ctr and use it with your left hand. So I guess not only the mapping is stupid.

Cheers
Horror Vacui
Anonymous, October 12, 2002 19:09
I don't understand the term "useless", if XFree86 is configured correctly for a 104 key PC keyboard, the penguin keys are mapped to Meta_L and Meta_R and the Menu key is mapped to Menu.  No need to use xmodmap.
Anonymous, October 13, 2002 8:11
Doh... useless for a vim user...
mrts, October 14, 2002 2:38
Horror Vacui:
why don't you map
* left winkey -> {
* shift+left winkey -> [
* right winkey -> <ESC>
* right winmenu -> }
* shift+right winmenu ]

Solves all my problems :)

mrts
Anonymous, October 14, 2002 11:51
Ctrl+[ is already mapped to escape...
[email protected], October 15, 2002 14:52
Arg, I am stuck on a windows box at school and even though it is nice that I can use vim, I cannot use xmodmap...:-/
[email protected], October 15, 2002 14:52
Arg, I am stuck on a windows box at school and even though it is nice that I can use vim, I cannot use xmodmap...:-/
remapESCkey@isForBitches, October 16, 2002 23:50
hmm, ESC key is in the wrong place, eh? . . . hah hahhah hah hah!!
[email protected], October 18, 2002 5:30
is there a way to remap capslock for the console, too?
(talking about linux)
i´m not using xfree very often.. indeed perhaps 10minutes/day for surfing.
and btw: ^c is mapped to esc, too. I´m using only ^c, but caps would
be even faster.
thanks, Daniel
[email protected], October 23, 2002 17:22
The answer to this last question is YES, if you are using KDE3...just go into the control panel under keyboard and choose to make the CapsLock another control key.  then you can use capslock-[ the way it was originally intended to be used in VIM (because stupid Microsoft put the capslock where the control key existed to help little ol' ladies to data entry on a windows box) and it is fluid as hell.  Forget you ever knew escape.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
SourceForge Logo