loading...
Cover image for Why you don't need to remap the escape key in Vim !

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

hamza profile image Hamza Tamenaoul ・1 min read

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

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>

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.

Posted on by:

hamza profile

Hamza Tamenaoul

@hamza

A software and information systems engineering student

Discussion

pic
Editor guide
 

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

 

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.

 

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.

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

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

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.