Update: this plugin is now obsolete and no longer needed as both neovim and
vim (since version
8.2.2345) have native support for this functionality.
FocusLost autocommand events are not working
in terminal vim. This plugin restores them when using vim inside Tmux.
Here's where that matters:
- vim-fugitive plugin uses
FocusGainedfor refreshing git branch in status line
- vim-gitgutter uses
FocusGainedfor refreshing ... (wait for it) git gutter
- vim-tmux-clipboard uses
FocusLostfor refreshing clipboard.
- (get in touch if you know other popular plugins that get improved)
vim-tmux-focus-events makes the
option work properly for terminal vim. So far, this was only working in a GUI
autoread feature comes handy when files are changed outside vim, for
example when resolving merge conflicts. When you come back to vim and try saving
a changed file you'll likely be interrupted with
autoread prevents this by automatically reading a file from disk
if it was changed. Works only if
autoread option is set (enable it with
set autoread in
Installation & Configuration
Vim plugin installation
git clone git://github.com/tmux-plugins/vim-tmux-focus-events.git ~/.vim/bundle/vim-tmux-focus-events
In order for Tmux to do its magic
focus-events option has to be set to
Enable that by installing
tmux-sensible plugin, or
by setting this line in
set -g focus-events on
Tested and working on:
- GNOME Terminal
Once installed, the plugin should "just work".
It will have no effect when running GUI vim or inside plain terminal (without Tmux).
Big chunk of code was taken and adapted from vitality.vim.
In April 2013 a patch was submitted to vim_dev mailing list that enables this functionality natively in vim. Once merged, the functionality from the patch will make this plugin obsolete. I hope that day comes soon.