Is there a simpler way to come back to NORMAL mode in vi?

The answer that has just been deleted mentioned 'delay'. I pressed CTRL+[ only once and it really brought me back to NORMAL mode after some delay. It seems that I just wasn't patient enough. However it's not clear why it takes so long.

PS: Other mode transitions are very quick...

  • Under the default configuration, you only need to press ESC (or Ctrl+[, but what vi user uses Ctrl+[???) once and wait for about a second. What happens when you press Ctrl+[ a single time? If it doesn't return you to visual mode, what did you put in your .vimrc to change this? – Gilles Apr 21 '18 at 20:39
  • @roaima Yes, more and more laptops/tablets lack ESC, but I can't imagine any vi user using such a keyboard without remapping `` or Tab or CapsLock or something. – Gilles Apr 21 '18 at 20:57

The reason there has to be a delay after hitting Esc is that it's not only a standalone key in vi that returns from INSERT mode to COMMAND mode, it's also generated via a terminal (emulation) as the prefix for many function keys.

For example, on my keyboard right now F1 generates the hex sequence 1b 4f 50. The first of those (1b) is Esc. Cursor right is 1b 5b 43. Escape by itself is 1b.

vi handles the differentiation by assuming that for a compound key sequence all the characters will come rapidly, but for a single use of Esc there will be a small pause after the character.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.