Git Product home page Git Product logo

vim-tmux-focus-events's Introduction

tmux-focus-events.vim

FocusGained and 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 FocusGained for refreshing git branch in status line
  • vim-gitgutter uses FocusGained for refreshing ... (wait for it) git gutter
  • (get in touch if you know other popular plugins that get improved)

Also, vim-tmux-focus-events makes the autoread option work properly for terminal vim. So far, this was only working in a GUI version.

The 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 E813:

vim E813

Improved 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 .vimrc).

Installation & Configuration

Vim plugin installation

  • Vundle
    Plugin 'tmux-plugins/vim-tmux-focus-events'

  • vim-plug
    Plug 'tmux-plugins/vim-tmux-focus-events'

  • Pathogen
    git clone git://github.com/tmux-plugins/vim-tmux-focus-events.git ~/.vim/bundle/vim-tmux-focus-events

Tmux configuration

In order for Tmux to do its magic focus-events option has to be set to on.

Enable that by installing tmux-sensible plugin, or by setting this line in tmux.conf:

set -g focus-events on

Testing

Tested and working on:

  • OS X

    • Terminal.app
    • iTerm2
  • Linux

    • GNOME Terminal
    • Terminator
    • XTerm
    • Konsole

Not working with NeoVim.

Usage

Once installed, the plugin should "just work".

It will have no effect when running GUI vim or inside plain terminal (without Tmux).

Other goodies

You might want to follow @brunosutic on twitter if you want to hear about new tmux plugins or feature updates.

Credits

Big chunk of code was taken and adapted from vitality.vim.

Other

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.

Licence

MIT

vim-tmux-focus-events's People

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.