edenzik / macvim

Automatically exported from code.google.com/p/macvim
0 stars 0 forks source link

mvim does not return focus to Terminal.app when using --no-fork option #148

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When using the --no-fork option to mvim (say as an editor for commands when 
using vi key 
bindings for bash), the terminal will wait on completion of editing the file in 
MacVim but MacVim 
does not return focus to Terminal.app when the file is closed unless MacVim 
also exits (e.g. the 
last window closing quits MacVim).

This happens when MacVim is already running or when it is not. 

It happens when there already files open in MacVim and when there are no open 
files.

To reproduce: open Terminal.app. Type "mvim -f". When MacVim loads, close the 
file ":q". The 
focus remains on MacVim, instead of returning to Terminal.app.

For "correct" behavior: in Terminal.app, "mvim -f". Now quit MacVim with Cmd-q. 
Focus returns 
to Terminal.app

Thanks for your attention to this issue!

Original issue reported on code.google.com by mark.m.f...@gmail.com on 10 Jan 2009 at 10:06

GoogleCodeExporter commented 9 years ago
The --no-fork flag has nothing to do with MacVim's focusing behaviour.  If you 
want a window to hide after 
you finish editing you have two options:

1. Set MacVim to hide when the last window closes 
(MacVim->Preferences->General->After last window 
closes...).  This only works if there is no more than one window so is not all 
that useful.

2. Set up an autocommand when you start 'mvim' to hide MacVim when _that_ 
window closes.  This is covered 
in the help file, see ":h macvim|/VimLeave"

Original comment by bjorn.winckler@gmail.com on 11 Jan 2009 at 5:59

GoogleCodeExporter commented 9 years ago
Thank you for the help.

As an additional note: this solution requires snapshot 35 or higher. The stable 
release build does not support the 
hide action on VimLeave events.

Thanks again.

Original comment by mark.m.f...@gmail.com on 12 Jan 2009 at 5:39

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I tried this suggestion #2 above, and I see how it works for a simple case of 
one vim window, but the "hide:" hides all Vim windows, and for me that's 
painful as I keep a lot of vim windows up in different desktops.

So now I'm using a different (and simple) approach that other's might find 
useful:

I use the autocommand to run a script on VimLeave.  Specifically, I've got this 
in my .vimrc:
    if has("gui_macvim")
        au VimLeave * !sh ~/.vimleave
    endif

Then, I only run macvim from the terminal via an alias - for me, the alias is 
"v":

    alias v="echo 'open /Applications/Utilities/Terminal.app; rm ~/.vimleave' > ~/.vimleave; mvim"

So, on exit, it runs a script that just opens (returns focus) to the Terminal 
app.  Its not perfect for multiple terminals, but could be modified to be 
better.  Really though, I just want to solve the iterative case where I enter 
mvim from the terminal, then return to the terminal, and repeat - without ever 
needing to use the mouse or hit command-tab or something else.

Original comment by ilikeles...@gmail.com on 20 Sep 2013 at 11:57

GoogleCodeExporter commented 9 years ago
I'd like to point out that TextMate (via the "mate" tool) and SublimeText (via 
"subl") do what the author is asking for.  It's really useful.  I don't 
understand why this is marked "invalid".  Basically, it saves me from hitting 
Command-Tab after I'm done with the edit job.

Original comment by kai.gros...@gmail.com on 25 Apr 2014 at 9:16

GoogleCodeExporter commented 9 years ago
Fair point.  It is no longer marked "invalid".

Original comment by bjorn.winckler@gmail.com on 26 Apr 2014 at 5:31

GoogleCodeExporter commented 9 years ago
To persons following this bug:  Does anyone have a workaround?

Original comment by joew...@gmail.com on 6 May 2014 at 4:19

GoogleCodeExporter commented 9 years ago
#7, I just hit Command-Tab...

Original comment by kai.gros...@gmail.com on 6 May 2014 at 7:48