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

Hamza Tamenaoul @hamza

About: A software and information systems engineer. Striving every day to give every piece of code the care it deserves.

Location:
France
Joined:
Dec 24, 2017

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

Publish Date: Sep 21 '20
6 6

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.

Comments 6 total

  • Vlastimil Pospichal
    Vlastimil PospichalSep 21, 2020

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

    • Hamza Tamenaoul
      Hamza TamenaoulSep 21, 2020

      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.

      • Vlastimil Pospichal
        Vlastimil PospichalSep 21, 2020

        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.

        • Hamza Tamenaoul
          Hamza TamenaoulSep 21, 2020

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

          • Vlastimil Pospichal
            Vlastimil PospichalSep 21, 2020

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

            • Hamza Tamenaoul
              Hamza TamenaoulSep 23, 2020

              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.

Add comment