vim freezes inside tmux

118

50

I’m using split panes in tmux – one being vim, the other being a shell.  Sometimes, around once a day, vim freezes.  I can move between panes, perform any tmux commands, just vim doesn’t react to anything.  This happens only with tmux.  My only solution for now is to kill that pane and create a new one.

Ondrej Slinták

Posted 2013-02-17T11:49:33.613

Reputation: 1 423

The same thing seems to happen to me when I save and press ^ z to put vim into the background too quickly afterwards. – gnucchi – 2017-06-08T14:56:34.190

6

This has never happened to me, and I have used tmux+Vim in that way extensively. This does not mean it cannot happen to you — but it means you will have to try to more precisely locate when it happens to try to figure out why. Relevant information is what terminal you are using. One idea: you are not just accidentally hitting Ctrl+S in the Vim window? In that case: press Ctrl+Q to "unfreeze".

– Daniel Andersson – 2013-02-17T12:07:48.207

Just to clarify, I use Ubuntu 12.10, tmux, zsh and gnome terminal emulator. My tmux prefix is rebound to ctrl+s. If I hit prefix + ctrl+s, vim freezes. ctrl+q without prefix unfreezes it. It puzzles me why this doesn't happen in shell though. – Ondrej Slinták – 2013-02-17T12:33:14.603

Answers

222

You might have hit Ctrl+S, which turns off flow control in terminals and stops the terminal from accepting input. It is reenabled by pressing Ctrl+Q.

Daniel Andersson

Posted 2013-02-17T11:49:33.613

Reputation: 20 465

7Holy ...! I've been having this issue for years, and never actually searched for a solution. This answer was the first solution I found, and it literally took me 3 seconds... All those hours wasted, and you had the solution just a couple of seconds away. I wish I could upvote you more (and downvote myself). Thanks! – simendsjo – 2014-10-10T21:29:35.137

Another time you might have this issue is when you're switching between editors (emacs and vim, for instance). They have different "save" commands, muscle memory confuses and hence the freezing. – Utkarsh Sinha – 2014-11-11T14:26:33.360

This being the accepted answer shows that the problem has nothing to do with tmux, but rather terminal flow control. Another way vim may appear frozen but tmux fine is to accidentally type a very processing-heavy command in normal mode. Ctrl-C does the trick, interrupting the command. – Brian Duncan – 2015-03-04T04:34:15.447

5and if it happens to be twice unlucky (a remote tmux session with C-q as prefix): Type Cltr-q, then :, and enter in tmux: send-keys C-q! – Paschalis – 2016-04-14T20:24:16.413

Thanks, you're my savior! I was close to really mad about all these sporadic freezes! :) – denied – 2017-12-07T13:42:19.867

+1 again, seems I've already +1 before... :-) – Mark – 2018-06-25T22:44:55.917

I only have this problem on Windows, because I don't use any other editor on Linux! I guess I'm not really portable. – jpaugh – 2018-10-09T22:36:17.617

Wow!!!. You have opened my eyes.

I had this issue for years and thought that the terminal hangs due to CPU/Memory resource issue. If I remote login, then I think it is a network issue. In all such occurrences, I just kill the terminal forcefully and start a new one. – RoboAlex – 2019-02-04T08:19:58.833

Thank you! You saved my day! – Aplusplus – 2019-10-21T14:04:39.567

Absolutely heroic read on the situation which saved me as well, thank you! – PROGRAM_IX – 2020-02-12T15:46:42.230

6When you're just starting to use vim/terminal editors as your main editor, this is a very common problem. Later on, you'll end up having :wq spread throughout all your documents (or ZZ, I don't judge) and feel silly. – Rob – 2013-07-29T15:14:42.200

14Amazing how you correctly guessed the problem from such such a vague description. Thanks! – DBedrenko – 2014-05-30T08:00:02.183

2

For me, this turned out to be a gpm problem. Run:

sudo service gym restart

See here for the related bug.

deuberger

Posted 2013-02-17T11:49:33.613

Reputation: 143

1

My story involved following

alias doodle='(f=$(mktemp); vim $f; echo $f)' # alias to quick edit a new file with whatever name

Now that I use this alias diff -u $(doodle) $(doodle) vim said Vim: Warning: Output is not to a terminal. After that the terminal froze. Usual keys wouldn't help, e.g. Ctrl+Q, Ctrl-C, etc.

Pressing ZQ helped. It would exit the vim that you stuck in, but whos UI you can't see.

I guess vim needs some flag (not figured out yet which) to show itself on screen when being executed from bach mode.

I hope it helps someone.

Yuriy Pozniak

Posted 2013-02-17T11:49:33.613

Reputation: 121