sjl / vitality.vim

Make Vim play nicely with iTerm 2 and tmux.
http://github.com/sjl/vitality.vim
MIT License
320 stars 30 forks source link

FocusGained works with Terminal.app (and tmux) #28

Open bruno- opened 9 years ago

bruno- commented 9 years ago

Hi, it seems I managed to get FocusGained work by using this plugin and tmux. Steps for this are below and I'm still a bit fuzzy why\ this works.

Tools:

How to enable FocusGained for terminal vim with the above tools:

That's it! FocusGained should now work. I've tested it with vim by setting the following autocommand:

au FocusGained * echom 'focus gained!'

A couple observations:

If this plugin is still maintained, do you think we could add these instructions somewhere (wiki maybe) so people know this is possible? Also, how about enabling the plugin when vim is running inside tmux so that let g:vitality_always_assume_iterm = 1 is not required?

chrischoy commented 9 years ago

Thanks,

Confirmed correct actions (FocusGain, FocusLost) on Terminal.app, OS 10.10

When you changed the .tmux.conf, make sure to reload or kill the tmux server. This caused me an hour to debug.

Unlike @bruno-, FocusLost also works seamlessly.

unphased commented 9 years ago

@bruno- @chrischoy My experience has been that FocusLost pretty much works, except that no matter what I tried I could not make it properly run echo or echom (while FocusGained had no problems with it). It is bizarre, but I am not about to lose sleep over it.

bruno- commented 9 years ago

Hey, it's good to hear that FocusLost works for you guys.. btw. how were you able to verify it works if echo or echom doesn't work?

I just tried and this au FocusLost * echom 'focus lost!' doesn't work for me too.

unphased commented 9 years ago

au FocusLost * stopinsert

bruno- commented 9 years ago

Thanks for sharing.. that one works!

On Tue, Mar 3, 2015 at 2:59 PM, Steven Lu notifications@github.com wrote:

au FocusLost * stopinsert

— Reply to this email directly or view it on GitHub https://github.com/sjl/vitality.vim/issues/28#issuecomment-76949529.