96

I've been using Vim for several months now via my web host (they allow putty access). All of a sudden, the escape key has become unresponsive. I cannot exist insert or any other mode by simply hitting escape. I have to hit F1 which brings up the help in vim and kicks me into command mode.

I'm most certain that my escape key on my keyboard is functioning fine since all of my windows shortcuts that use the escape key operate normally.

I know this is a ridiculous question and I'm certain there's a lot more to look into regarding a solution. What I really need is a solid lead as to where to start looking.

Things that might help:

  1. I'm using vim via putty
  2. I'm logging in using jailshell
  3. I'm not root

6 Answers6

228

I had mistakenly hit Ctrl + s, and got stuck in the insert mode. To get out of it use Ctrl + q.

soandos
  • 24,600
  • 29
  • 105
  • 136
bhaskar
  • 2,281
31

Try using Ctrl-[ instead of Esc.

What is the result of:

python -c "print ord(raw_input('char '))"

when you press Esc and Enter? It should be "27". What is the result of pressing Ctrl-V then Esc?

Have you checked all the settings in PuTTY to see if they're reasonable?

Are you using Bash on the remote system? Look at the output of

bind -p | grep -i '\\e' | less

and see if you see anything unusual. Do you have a file called ~/.inputrc? Look at its contents to see if anything is unusual.

Look at your ~/.vimrc and see if everything's OK, too.

11

Maybe you are using the insert mode.

'insertmode' 'im' 'noinsertmode' 'noim'
boolean (default off)
Makes Vim work in a way that Insert mode is the default mode. Useful if you want to use Vim as a modeless editor. Used for |evim|.
[...]
- Use CTRL-O to execute one Normal mode command |i_CTRL-O|). When this is a mapping, it is executed as if 'insertmode' was off. Normal mode remains active until the mapping is finished. - Use CTRL-L to execute a number of Normal mode commands, then use Esc to get back to Insert mode. Note that CTRL-L moves the cursor left, like does when 'insertmode' isn't set. |i_CTRL-L|

I suggest editing ~/.vimrc to add the following line:

set noinsertmode         "disable insert mode
SandRock
  • 572
9

Find a strange way to quit:

copy some thing and paste it, then you can use <esc> or <ctrl-c> or <ctrl-[> to quit

see gif: https://i.sstatic.net/NBnns.gif

Sangria
  • 101
0

I had this problem, but realized it was from accidentally changing the SCIM input mode to "Other - RAW CODE". I changed it back to English/Keyboard and did not have any more problems.

0

The top answer didn't work for me here and even ctrl + c couldn't get me out. If yours is as stuck as mine, here's what worked for me:

  1. Closed the current stuck terminal.
  2. Reconnected with a new terminal.
  3. Opened the file with Vim
  4. Got a notice that it was already being edited.
  5. It gave me the option of R for recovery which I chose.
  6. Back into vim for the file without issue.
Wes
  • 101