Unicode escape is ctrl+[ , why does this work in terminal or vim, but not safari or other parts of OS

keybindingskeyboardterminalvi

When i'm working in VIM i'll often times use ctrl+[ to exit insert mode. But if i need to press escape in other parts of the OS ctrl+[ does not act the same way as escape.

For example if search a page in safari you can't escape out of the search with ctrl+[

can anyone shed light why this is and possibly tell if it's possible to get ctrl+[ to always be escape with out custom plugins or weird 3rd party software?

Best Answer

For example if search a page in safari you can't escape out of the search with ctrl+[

It's because Safari is not operating in an ASCII/ANSI Terminal environment.

The Escape character is

  • octal: \033
  • hexadecimal: \x1B or ^[
  • decimal: 27

It's just a series of characters the terminal looks for that interprets it as actions or special characters.

As for working in vim (or vi), you aren't limited to sending ^[ (^ Control[), you can simply press the Escape key. It will do the same thing.