Terminal got hanged when editing something in vi
I was making some changes to a remote file in vi using the terminal when I accidently pressed Ctrl+S instead of :wq
.
Now everything got hanged. I tried Escape,:q!
and all sorts of vi commans but nothing is responding. The Terminal Screen is stuck. I can't close the Terminal session as of now as it will lead to loss of all the changes. Please suggest what should be done
Ctrl+Q will undo Ctrl+S. These are ancient control codes to stop and resume output to a terminal. They can still be useful, for instance when you are tailf
-ing a log file and something interesting scrolls by, but this era of unlimited scrollback buffers has really obsoleted them.
I would like to complement zwets' accepted answer.
You can see the meaning of special keypresses by issuing the commands stty -a
and man stty
.
stty -a
prints all current settings of the terminal. The result in my terminal:
speed 38400 baud; rows 33; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?;
swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk > -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke
man stty
prints the manual of stty. The part that is relevant here:
Special characters:
start CHAR CHAR will restart the output after stopping it stop CHAR CHAR will stop the output