DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 968,873 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for Why you don't need to remap the escape key in Vim !
Hamza Tamenaoul
Hamza Tamenaoul

Posted on

Why you don't need to remap the escape key in Vim !

Vim by its nature is very heavy on the <Esc> key usage. It's very important in the modal editing philosophy of the editor. But when we are talking about Vim, we are talking about minimal hand movement in the first place, since it is the reason behind all of its design choices. For this reason many have found the usage of the <Esc> very unintuitive to use, and prefer to map it to a more easier to access key combination. Many tutorials over the internet suggest changing it to a combination close to the home row like jk, a combo I did not personally find useful.

However the designer of Vim did not forget about the user that might find exhausting to use <Esc>. When diving in the documentation of Vim, we can notice in the intro page by typing:

:help escape
Enter fullscreen mode Exit fullscreen mode

We can read on this page a more clever key combination that is already built in the default Vim configuration.

<Esc>   escape  CTRL-[  27  escape  <Esc>
Enter fullscreen mode Exit fullscreen mode

We can see that <Esc> is also mapped to <C-[>. And this is very interesting since Vim by default gives us a more easier to use key combination for the escape key out of the box.

It can take some time to get used to using this key combination, but it will quickly become your favorite since, you can start from it to make other more interesting key combinations; like an escape key of the built-in terminal.

What do you think about this key combination, or do you already use a more interesting one in your configuration.

Top comments (6)

Collapse
 
vlasales profile image
Vlastimil Pospichal

<C-[> is impractical for me because I access [ via Alt-Gr. The <Ctrl-c> combination is more convenient for me.

Collapse
 
hamza profile image
Hamza Tamenaoul Author • Edited on

Yes it's true that is not practical for everyone ! It depends on your keyboard map. And sadly the vim keys are only optimized for the en_us layout.

Collapse
 
vlasales profile image
Vlastimil Pospichal • Edited on

It's not that bad, I just use other abbreviations. Vim allows me extensive remapping according to my habits. In addition, I can save the debugged configuration on GitHub, for example, and distribute it to all my computers.

Try use <Ctr-c> to exit insert mode without configuration.

Thread Thread
 
hamza profile image
Hamza Tamenaoul Author • Edited on

It's an interesting shortcut, I'll try it ! thanks !

Thread Thread
 
vlasales profile image
Vlastimil Pospichal • Edited on

Next: Try <Alt-d>d or <Alt-k>, <Alt-x>, etc.

Thread Thread
 
hamza profile image
Hamza Tamenaoul Author

I will see if I'll get to using the Alt key, since with i3, I am already using the Super and the Ctrl key in many programs.

DEV has this feature:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. πŸ›