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
  • what are your terminal settings? ie what exactly is the TERM environment variable set to (in the remote shell)? – quack quixote Apr 11 '10 at 21:28
  • $TERM is set to 'xterm' – Levi Hackwith Apr 11 '10 at 21:33
  • Does Ctrl-[ work? What do you get if you press Ctrl-v then escape? It should show as ^[. – Dennis Williamson Apr 11 '10 at 21:35
  • The Ctrl-[ worked. Rock on! This saves me a lot of frustration. Is there any chance you can explain why esc no longer works? Also, please post your comment as an answer so I can accept it. – Levi Hackwith Apr 11 '10 at 21:42
  • My first thought when reading this: "Oh he broke his 'Get me the heck out of here' button" – Daniel Nov 10 '16 at 17:41
up vote 12 down vote accepted

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.

  • Ctrl-c should end insert-mode as well (the '[' is sometime a bit tricky to get on some keyboards) – akira Jun 24 '10 at 9:42
  • I ran the python script and it came back as an empty string. How do I fix this? I'm using putty. – Keith Apr 26 '12 at 17:05
  • @Keith: Did you try any of the other diagnostic suggestions? – Dennis Williamson Apr 26 '12 at 17:25
  • ctrl+[ worked for me for whatever reason, no idea what i did to get my vim stuck. – Derek Adair Dec 10 '15 at 22:09

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

  • 6
    That's not insert mode that's XOFF. You can disable software flow control by doing stty -ixon (add it to your ~/.bashrc). Then that keystroke will be available to be bound to something else. By default in Bash it's bound to forward-search-history (the opposite of Ctrl-r). Ctrl-q (Bash quoted-insert) will also be available. – Dennis Williamson Jul 2 '12 at 14:18
  • @DennisWilliamson Wouldn't .bash_profile be a better place? There's no need to turn it off in non-interactive shell, is it? – Piotr Dobrogost Mar 4 '14 at 22:14
  • 1
    @PiotrDobrogost: "When an interactive shell that is not a login shell is started, Bash reads and executes commands from ~/.bashrc, if that file exists." .bash_profile is only executed when Bash is a login shell. "So, typically, your ~/.bash_profile contains the line if [ -f ~/.bashrc ]; then . ~/.bashrc; fi" – Dennis Williamson Mar 4 '14 at 22:22
  • 2
    thanks! that's what I did. So glad other people habitually save like that regardless of program. :-) – NullVoxPopuli Aug 27 '14 at 12:11
  • 2
    Saved me twice. – Elazar Apr 22 '16 at 12:51

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
  • 1
    In my case it stuck in insert mode because i had accidentally used ` -y ` in commandline As said in manual: -y Start Vim in easy mode, just like the executable was called "evim" or "eview". Makes Vim behave like a click-and-type editor. To exit this "ease mode" just use <kbd>CTRL</kbd> + <kbd>l</kbd> (L lowercase) as said by +SandRock – ton Jan 22 at 13:06

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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