3

I use Vim in a tmux session, and recently I've noticed that Vim is raising an alert after a few seconds when I switch to another tmux window. Nothing has happened in Vim after I move windows - usually I do some edits and write the file with :w and then move in tmux. A few seconds later Vim alerts and tmux flashes that Vim needs attention.

Why is Vim being so needy? How can I prevent this?

Update #1

Output from :au FocusLost as requested:

:au FocusLost
--- Auto-Commands ---
Press ENTER or type command to continue

Links to .vimrc and .tmux.conf:

Update #2

Using versions Vim 7.3 and tmux 1.6. This whole thing is happening when in an SSH session where tmux is running. I switch away from the Vim window using tmux keys Ctrl+A Ctrl+N as per the tmux conf.

2

2 Answers 2

2

Auto Commands and Focus

Check to see if you have any Auto Commands (:au or :autocmd) associated with losing focus. These are the commands you can run in vim:

:autocmd FocusGained
--- Auto-Commands ---
fugitive_status  FocusGained
    *         call fugitive#reload_status()

:au FocusLost
--- Auto-Commands ---
Press ENTER or type command to continue

The above is showing how you'd check this. The 1st example uses the fullname of the command, :autocmd. The 2nd shows the short form of the command, (:au). You can provide group names to either of these to show a subset of the list of Auto Commands.

Maybe you need Vitality?

I'm not that familiar with this but I did come across this plugin named: Vitality which looks to help smooth things out with iTerm2 and tmux. It's not entirely clear to me what this fixes but it might be worth a look.

excerpt from webpage

For example: it restores the FocusGained and FocusLost autocommands when running Vim in iTerm 2, even through tmux!

References

5
  • I don't seem able to put newlines in the comment - so here's another try: pastebin.com/YjkwiYhA - So it looks like there's no LostFocus event which is occurring
    – mafrosis
    Commented Aug 31, 2013 at 2:31
  • @mafro - add them to your question. It's OK to refine it as things develop. Just click the edit buttion.
    – slm
    Commented Aug 31, 2013 at 2:32
  • @mafro - do me a favor and temporarily move your .vimrc file out of the way so we can just focus on tmux. Does the problem persist when you do this?
    – slm
    Commented Aug 31, 2013 at 2:40
  • Removing .vimrc does indeed make the issue disappear
    – mafrosis
    Commented Aug 31, 2013 at 2:47
  • @mafro - good that's pretty huge progress. So we know it's a vim issue then. I'll keep digging.
    – slm
    Commented Aug 31, 2013 at 2:48
0

The vim-gitgutter plugin was causing the unexpected Vim alarms. The following line added to my .vimrc fixed it:

let g:gitgutter_realtime = 0

The following comment on the source gave me the solution: https://github.com/airblade/vim-gitgutter/issues/105#issuecomment-23055765

Thanks @slm for pointing in the right direction :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .