The Esc
key is not a convenient key to hit on the keyboard. When learning to use Vim, you often get the recommendation to remap your <Caps Lock>
key to your <Esc>
key (i.e. when you hit your Caps Lock
key the computer treats it as if you’ve hit the Esc
key). The argument is typically:
- the
Esc
key is inconvenient to hit - the
Caps Lock
key is seldom, if ever, used - the
Caps Lock
key is easy to hit
While these are all valid points, this argument overlooks the negative impact of customization and muscle memory.
Muscle Memory
Usually muscle memory is a good thing. Your body performs some routine process (like hitting a certain key) without concentrating on performing the task. When you use Caps Lock
as Esc
, you build up that muscle memory. This is great until you’re working on a machine where this customization is not in place. Perhaps you’re SSHing into a machine or using someone else’s laptop, whatever the reason Caps Lock
no longer behaves as Esc
. In this situation you’ll be fighting muscle memory every step of the way.
Using CTRL-[
In Vim hitting the CTRL
key and the [
key at the same time (often written CTRL-[
) is the same as hitting the Esc
key. Vim help even includes this recommendation (see :help c_CTRL-[
)
Note: If your
key is hard to hit on your keyboard, train yourself to use CTRL-[.
While some will argue that shifting your hands to hit these two buttons at the same time is inefficient, this has become part of my muscle memory and is now effortless. This muscle memory that is applicable on all Vim installations by default has served me well.
Leave a Reply