CapsLock… who needs it? If you’ve got a CapsLock problem, there is help. Otherwise, if you happen to be an vi addict, then swapping CapsLock with ESC is pretty awesome since that Meta key is only rivaled by the space bar in terms of key presses per second.
Nowdays, a default Debian install with Gnome comes with a gnome-control-center capplet for gnome-keyboard-properties. If you go System->Preferences->Keyboard->Layouts->Layout Options->CapsLock Key behavior->”Swap ESC and CapsLock” then your ESC and CapsLock are swapped. More or less. I found a few problems with this on my T61p.
- The little Thinkpad CapsLock LED does not do the swap. It will toggle as you hit your new Meta (ESC) key, not your new CapsLock key.
- Hibernation: Depending on what combo of ESC and CapsLock are set when you initiate hibernation, when you come out of hibernation they can be in an inconsistent state. The only GUI solution I’ve found to this is to reset my Keyboard Layout Options to the defaults, and then do the “Swap ESC and CapsLock” GUI chain again. (No, I haven’t tracked this bug down and filed a report… I suspect it’s somehow unique to Thinkpads.)
Old skool to the rescue… Xmodmap.
Edit (create if non-existent) your ~/.Xmodmap file as follows:
! Swap Caps_Lock and Escape. ! see man xmodmap remove Lock = Caps_Lock keycode 0x9 = Caps_Lock keycode 0x42 = Escape add Lock = Caps_Lock
And restart your X session. Bam. The above two issues are solved.