I’ve decided I really really want to stop reaching to the top of the keyboard to hit escape every time I want to get out of insert mode in Vim.
In a flash of what should have been obvious, I realized that this wasn’t a
.vimrc-thing. This was a
The obvious answer for me was to map the capslock key to another escape key, but you can map it do anything.
(Even nothing at all)
Linux machines - introducing xmodmap
On Linux machines, you can create a dotfile in your home directory to remap keys. This should work for any desktop/window manager as it changes a configuration in the X server itself.
Create a file named
~/.Xmodmap and insert these lines:
! Make Caps Lock = Escape clear Lock keycode 0x42 = Escape
Lines that start with a bang (!) are comments. The syntax is pretty clear.
Windows machines - PuTTy and the like
Rather than mess with keycodes and translations in PuTTy, I just googled until I found a utility that does the same global substitution as above but for Windows.
SharpKeys is a simple utility that will let you map any key to any other key.
Open the utility, and click
In the left pane click
Type Key and then press the Caps Lock key
In the right pane click
Type Key and press the Escape key
Once you are done, click the Write to Registry button and you’ll be told to log off or reboot for the changes to take effect.
This not only solved my desire to have a closer key to use to get out of insert mode in vim, but it also prevents me from typing in all caps anywhere else. Because, seriously, who needs a Caps Lock key anymore?