How to get back to insert mode in VIM when you accidentally hit C-x C-s

64

12

Given this vim session:

% vim test-file.txt
iHello there!C-x C-s

How do I get back to insert/command mode again? (C-x C-s means Control-x Control-s, not sure if it's normal vi terminology for keyboard shortcuts)

I know there's some way to get out of this and into insert/command mode again, but I just can't remember how and searching Google or superuser hasn't yielded me anything.

This happens since I mostly use emacs, but I use vim for remote hosts where I don't have emacs installed. Occasionally I do this and I figured I should learn how to get out instead of just restarting the terminal every time.

gaqzi

Posted 2010-02-15T16:48:36.040

Reputation: 1 058

6

Aside: watch out for vim's decrement shortcut bound to C-x. I learned about this one the hard way. Full story on an old blog post: http://wemmick.blogspot.com/2005/09/geeky-friday-little-known-vim-feature.html

– Doug Harris – 2010-02-15T17:19:48.260

@DougHarris, this blog post is priceless! uhuhuhuhuuh thanks for sharing! – theMarceloR – 2019-03-17T22:38:28.057

Answers

77

C-q. in a console C-s is scroll lock, resume is C-q

Justin Smith

Posted 2010-02-15T16:48:36.040

Reputation: 3 746

0

If C-q does not work, this has worked for me:

  • (1) close the console,
  • (2) open a new terminal,
  • (3) reopen the file in vi,
  • (4) vi will warn you that the file is already open
  • (5) enter 'R' for retry and save with w-q

jschnasse

Posted 2010-02-15T16:48:36.040

Reputation: 101