21

I have two different machines (home and work) running Ubuntu 18.04. Last night vim froze at home. I was in insert mode and typing and went to save (esc :w) and nothing happened. The status bar still reads -- INSERT --, the cursor is still blinking where it was. I was stuck. I couldn't find a way out. I couldn't type (nothing happened when I type), I couldn't move around (the up and down arrows did nothing). It was stuck in insert mode with the cursor blinking where it was.

I was definitely multitasking and probably hit some other keys in there, but I don't know what keys. It was late, though, so I closed the terminal window and tried again (I was entering a git commit message). It happened again partway through my typing so I switched to git commit -m "don't need an editor for this" instead. And then I shut down my computer and stopped working.

I figured I was just tired, but then it happened to me today at work on a different laptop altogether. Again I was multitasking and can't swear I didn't type any bizarro key sequence but if I did it was accidental. And other tabs in the same terminal aren't frozen.

I'm used to getting trapped in visual mode in vim. That's a trick I've learned. But stuck in insert mode? Any ideas on what I might've done and how to get out of it?

Per a comment suggestion I tried looking at .viminfo but the only .viminfo I see is owned exclusively by root and only appears to show things I would have edited with sudo:

# Input Line History (newest to oldest):

# Debug Line History (newest to oldest):

# Registers:

# File marks:
'0  1  0  /etc/neomuttrc
|4,48,1,0,1531789956,"/etc/neomuttrc"
'1  1  66  /etc/apt/sources.list.d/signal-bionic.list
|4,49,1,66,1530816565,"/etc/apt/sources.list.d/signal-bionic.list"
'2  51  0  /etc/apt/sources.list
|4,50,51,0,1530816531,"/etc/apt/sources.list"

# Jumplist (newest first):
-'  1  0  /etc/neomuttrc
|4,39,1,0,1531789956,"/etc/neomuttrc"
-'  1  66  /etc/apt/sources.list.d/signal-bionic.list
|4,39,1,66,1530816565,"/etc/apt/sources.list.d/signal-bionic.list"
-'  1  66  /etc/apt/sources.list.d/signal-bionic.list
|4,39,1,66,1530816565,"/etc/apt/sources.list.d/signal-bionic.list"
-'  51  0  /etc/apt/sources.list
|4,39,51,0,1530816531,"/etc/apt/sources.list"
-'  51  0  /etc/apt/sources.list
|4,39,51,0,1530816531,"/etc/apt/sources.list"
-'  51  0  /etc/apt/sources.list
|4,39,51,0,1530816531,"/etc/apt/sources.list"
-'  51  0  /etc/apt/sources.list
|4,39,51,0,1530816531,"/etc/apt/sources.list"
-'  1  0  /etc/apt/sources.list
|4,39,1,0,1530816447,"/etc/apt/sources.list"
-'  1  0  /etc/apt/sources.list
|4,39,1,0,1530816447,"/etc/apt/sources.list"
-'  1  0  /etc/apt/sources.list
|4,39,1,0,1530816447,"/etc/apt/sources.list"
-'  1  0  /etc/apt/sources.list
|4,39,1,0,1530816447,"/etc/apt/sources.list"

# History of marks within files (newest to oldest):

> /etc/neomuttrc
    *   1531789952  0
    "   1   0

> /etc/apt/sources.list.d/signal-bionic.list
    *   1530816564  0
    "   1   66
    ^   1   67
    .   1   66
    +   1   66

> /etc/apt/sources.list
    *   1530816454  0
    "   51  0

It seems odd that I wouldn't have an unprivileged .viminfo but I did sudo udpatedb and locate .viminfo and still didn't surface more than the one root-owned file.

  • Do you have a ~/.viminfo file? Vim generates this and it will contain the last few commands entered (along with much other data). If you have one, does it shed any light on this? – Kusalananda Oct 29 '18 at 21:28
  • Don't judge me for using vim to scan files I shouldn't be editing, but ... expanded my question to include info -- I don't see a user owned .viminfo file at all? – Amanda Oct 29 '18 at 21:41
  • @mosvy I don't think those keys do flow control inside of Vim though (not on my system at least). – Kusalananda Oct 29 '18 at 22:15
  • @Kusalananda they do on mine ;-) (also tried without a .vimrc, and it's also mentioned at :h ^Q) – mosvy Oct 29 '18 at 22:19
  • @mosvy that's exactly what it was. Or at least Ctrl-q solved it. Weird that I haven't encountered this before, in years of using vim but it's wholly consistent with me being tired – Amanda Oct 29 '18 at 22:21
44

One key that I frequently fat-finger by mistake is CtrlS; that stops all terminal output until a CtrlQ is typed.

That's the XON/XOFF control-flow, which is enabled by default, and ^S and ^Q are the default VSTART and VSTOP keys respectively -- see the stty(1) and termios(3) manpages.

You can disable it with:

stty -ixon

vim will not reenable it as part of its changing the terminal settings.

| improve this answer | |
  • Should this be in .profile? – Raffi Khatchadourian Oct 31 '19 at 19:56
  • 2
    Just up-voted purely for the Ctrl Q. That saved me! Thank you! – codingjeremy Dec 11 '19 at 23:38
  • If, for whatever reason -- you globally remapped ("inactivated") Ctrl-Q (e.g. to avoid accidentally quitting Firefox), adding stty -ixon to your ~/.bashrc enables Ctrl-q in terminals. In my case, Ctrl-s was freezing Vim and I could not get back to it ... until I made that .bashrc modification. Details here: superuser.com/a/1328326/409327 – Victoria Stuart Mar 1 at 18:47
  • I feel like alot of people suffer from this issue seeing how common Ctrl-s is as a keybind. Even though vim does have swap files which most of the time save work even if you force quit the shell because you froze, this definitely explains what happened and saves the headache of having to recover swap files! Thanks! – yosefrow Aug 4 at 13:59
  • 2
    Also, I think its ironic, that the keybind that usually saves you screws you up in vim (ctrl+s) and the keybind that usually screws you up, saves you (ctrl+q) – yosefrow Aug 4 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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