4

If you have an American English keyboard, pressing Ctrl-[ (control plus left square bracket) is equivalent to pressing Esc. This provides an easy way to exit from insert mode.

source: https://vim.fandom.com/wiki/Avoid_the_escape_key

So I just learned this after spending the last 3 months full time going nuts over why pressing escape double for me activated some function that I didn't want. Because obviously double escape should not be different from single escape.

So turns out I have the Ctrl-[ key in use... Which turns out is something poisoned.

Yeah so I'm gonna keep myself civil and not ask why on earth this is a thing, but just kindly ask if there is a way to turn that "feature" off?

peterh
  • 1,147
  • 3
  • 16
  • 35
Steven Roose
  • 143
  • 4
  • 4
    You can't remove it, because this is the way terminals work; the escape key is Control+[. I wrote a page with some explanation and history on it: https://bestasciitable.com/ – Martin Tournoij Apr 24 '20 at 18:32
  • 4
    That's because it is the same key, just another way of specifying. See also http://ascii-table.com/control-chars.php – Christian Brabandt Apr 24 '20 at 18:35

1 Answers1

9

Vim is a terminal based program and has its key handling from the terminal. Also the GUI variants still act like this (with a few extensions).

In a terminal Ctrl-A is ASCII 0x01, Ctrl-B is ASCII 0x02 and so on. Ctrl-Z is 0x1A and Ctrl-[ is 0x1B.

And 0x1B is also the ASCII code for ESC.

Vim can't differentiate between ESC and Ctrl-[, because it gets the same key code when either is pressed.

For the same reason it can't differentiate between Ctrl-I and <TAB>. Both produce 0x09.

Ralf
  • 9,197
  • 1
  • 11
  • 30