5

I'm using Vim 8.1 from homebrew on MacOs 10.14.6. Whenever I exit vim back to the terminal, the first keypress in the terminal afterward results in a beachball and CPU spike to 100%, with terminal listed as "not responding" in Activity Monitor. The spike lasts for 5 to 25 seconds, then the terminal is fine until the next time I exit vim. vim is the only thing that seems to be causing this, so far. This behavior is recent -- this same configuration had been working fine before -- although I have updated vim from homebrew in an attempt to fix the problem.

I'm wondering if there's a network issue somewhere (I'm behind a corporate firewall where the admins change the rules occasionally), or some other interaction betweeen vim and terminal that I'm not accounting for.

  • Why would there be networking between vim and the terminal? Have you tried using any of the profile/debug options to get a look at where the time spike is happening? How are you running/using/quitting vim in this process? Data is the key to solving any performance mystery. – D. Ben Knoble Sep 17 '19 at 18:26
  • At a guess: if you have 100s of files open, vim might be dealing with cleaning up swap files... but again, this is a guess. We need more data – D. Ben Knoble Sep 17 '19 at 18:27
  • I'm on the command line, in a bash shell. I type vim ...file..., and when I exit vim the terminal beachballs as soon as I type anything on the keyboard. This does not happen for anything else I run from the terminal. I suspect network because that's what could have changed recently since it's beyond my control. vim is the binary installed by homebrew. I may still blame bash for the problem, but the odd thing is it only affects vim. – Andrew Barnett Sep 17 '19 at 21:09
  • Again: profile/log—realtime data is necessary here. Is it 100s of files, or a single file? Vim doesnt network unless you use netrw to edit files over a network, or you touch something on an NFS (and then its the filesystem networking, not vim). – D. Ben Knoble Sep 17 '19 at 23:09
  • 1
    does this still happen if you disable your vimrc? vim --clean (others)? – Lie Ryan Sep 18 '19 at 00:47
  • If you quit Vim but don't press a key for, say, one minute, then does the terminal hang the first time you press a key, or does the problem only occur if you start typing soon after quitting Vim? – Rich Sep 18 '19 at 08:34
  • 1
    What is the terminal displaying before and during the hang? If you run Vim with the command vim && echo hi does the hi display immediately after quitting Vim, or does that also cause the hang? – Rich Sep 18 '19 at 08:36
  • If you open another terminal and execute the command ps | grep [Vv]im in it while the hang is in progress, what is the output? – Rich Sep 18 '19 at 08:39
  • 1
    Behavior remains with vim --clean. – Andrew Barnett Sep 18 '19 at 16:46
  • vim && echo hi prints the hi and then beachballs -- so that points to a non-vim issue, I would think. – Andrew Barnett Sep 18 '19 at 16:46
  • 1
    Behavior seems to affect only a single terminal window at a time -- if I open another terminal, the other doesn't have the same problem. – Andrew Barnett Sep 18 '19 at 16:51
  • I don't know what's causing your issue, but I get a similar kind of problem when I execute vim from a bash script which I have sourced. On the way out of the sourced script, the script does: eval "unset my_var; (exit $my_var)" and it's this part which hangs inexplicably. I've noticed it especially with vim, but possibly it's occurring with other commands in similar situations. When I changed (exit...) to return $my_var it seems to have made the problem go away. That shouldn't have made a noticeable difference, but it apparently did. Running bash 3.2.57(1) and vim 8.1 patch 1-2400. – jrw32982 Dec 13 '19 at 00:46
  • I have TabNine installed (https://tabnine.com), and I think something with its process was causing the problems. Odd that a reboot didn't fix it, unless it wasn't finding a network server it needed. – Andrew Barnett Dec 17 '19 at 15:27
  • It seems that I just started having the same issue, but I don't have TabNine installed. Did you ever figure out a solution? – igal Jul 21 '20 at 14:38
  • I haven't noticed a problem lately, although I've since upgraded laptop and macOS. I'm still running TabNine. – Andrew Barnett Jul 23 '20 at 20:45
  • I have a similar problem after Mac upgrade to Big Sur, any solution to this? – Natasha Apr 15 '21 at 18:21

0 Answers0