Vim Tips Wiki
Advertisement
Tip 342 Printable Monobook Previous Next

created October 11, 2002 · complexity intermediate · author mrts · version 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. You may have to use xmodmap directly (from ~/.xinitrc in *BSD or whatever).

Here's part of my xmodmap:

keycode 115 = braceleft
keycode 116 = Escape
keycode 117 = braceright

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.

Comments

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 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.


Why don't you map

  • left winkey -> {
  • shift+left winkey -> [
  • right winkey -> <Esc>
  • right winmenu -> }
  • shift+right winmenu ]

Ctrl+[ is already mapped to escape.


> Is there a way to remap capslock for the console, too?

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.


Advertisement