• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Computing / Use CTRL-[ as Esc in Vim

Use CTRL-[ as Esc in Vim

Last updated on August 2, 2019 by Sal Ferrarello

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.

Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit
Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Computing, Dev Tips, Draft, Recommendations Tagged With: vim

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in