Wednesday, June 11, 2008

Vim freezes with Ctrl+S

lol ... now this is a very strange and funny problem. Most of us are used to ctrl+s for saving files, but on vim it just freezes everything. Specially if you are on a ssh session, have just added 100 lines of code to your cool new application, ctrl+s can effectively ruin all the fun all of a sudden. Well the solution to this problem was not very complicated, try pressing ctrl+q ;)

Well, found the solution to this problem somewhere here :: http://vimdoc.sourceforge.net/cgi-bin/vimfaq2html3.pl#32.1. And this is what it says ::

Many terminal emulators and real terminal drivers use the CTRL-S key to
stop the data from arriving so that you can stop a fast scrolling display
to look at it (also allowed older terminals to slow down the computer so
that it did not get buffer overflows).  You can start the output again by
pressing the CTRL-Q key.

When you press the CTRL-S key, the terminal driver will stop sending the
output data. As a result of this, it will look like Vim is hung. If you
press the CTRL-Q key, then everything will be back to normal.

You can turn of the terminal driver flow control using the 'stty' command:

$ stty -ixon -xoff

or, you can change the keys used for the terminal flow control, using the
following commands:

$ stty stop 
$ stty start