I used to have it mapped to escape but once I started using tmux I mapped caps lock to control and never looked back. Much more versatile than escape and ctrl+[ will do the same thing (although it's proving hard to break the habit of pressing escape instead).
Best of both worlds: KeyRemap4MacBook has a setting where Control acts as Control when held down, but acts as Escape if typed alone. This in combination with setting Caps Lock as Control in OSX is all sorts of awesome.
Unmap your escape key, that will force the habit. I did this when I moved my control and meta keys to the left thumb of my kinesis keyboard, and it helped train me not to hit the old keys.
I've tried this in the past but it made both escape and ctrl+[ no longer function. What worked for you?
Under OSX I used a tool called KeyRemap4MacBook which adds an item to the control panel that lets you reconfigure keys. I just tested it, you can can disable the escape key, but Ctrl-[ still works like you'd expect.
imap jk <Esc>
Hitting jk in insert mode for escape is wonderful.
Re:Coming Home to Vim
by dickfickling on Monday July 09, 2012 @04:24PM
(#4220199)
I had to create a modified keyboard layout, starting from one in /usr/share/kbd/keymaps.
Use the showkey command to find out what keycode the caps lock key generates (mine is 58), then add a line in your layout file to the effect of
keycode 58 = Escape Escape Escape Escape Escape
Finally, load your new layout using loadkeys /usr/share/kbd/keymaps/i386/{yourlayoutname}/{yourlayoutname}.map.gz
I finally tried this out today:
(while TERM=linux)
keys.kmap:
keymaps 0-127
keycode 1 = CtrlL_Lock
keycode 58 = Control
sudo loadkeys keys.kmap
This works, but I haven't set this up to load on startup yet.
Re:Coming Home to Vim
by johncoltrane on Monday July 09, 2012 @03:00PM
(#4219794)
I think you have to play with loadkeys and a custom mapping.
However, both methods I know for doing this only work inside an X server - does anybody know a good way to remap keys without X?