The "Edit in External Editor..." feature is great. I would like to
have the same functionality from the command line (specifically, from
my email client, mutt). Can you suggest how this might be done?
The standard approach is to call Vi in the terminal. However, I would
like to edit all my files in MacVim. I can't simply issue an "open -a
MacVim" command since this returns; the call must be a blocking one.
Perhaps one of the scripts (gvim) blocks?
Ideally, I would like the call to open the file in a buffer in a new
tab in an existing window of MacVim, and to return once I've deleted
the buffer. Should this be done with the remote client/server
functionality?
Currently I have this working, through the following route: I call a
script instead of MacVim. The script creates a lock file, calls
MacVim, and then waits for the lock file to be removed. When I'm done
editing the file, I issue a command in Vim that writes the file,
deletes the buffer and removes the lock file. The script and the
function are copied below.
My solution works, but I'm wondering if there's a more direct route --
one that doesn't write lock files. Any thoughts or comments would be
appreciated.
Kudos for doing such a great job with MacVim.
--Marc
Script that creates a lock file, calls MacVim, and then waits for the
lock file to be removed:
#! /bin/tcsh
if !(-f $1) touch $1
touch $1.lck
open -a MacVim $1
while (-f $1.lck)
sleep 0.1
end
Vim function that writes the file, deletes the buffer, and then
removes the lock file:
Cyclify wrote: > The "Edit in External Editor..." feature is great. I would like to > have the same functionality from the command line (specifically, from > my email client, mutt). Can you suggest how this might be done?
> The standard approach is to call Vi in the terminal. However, I would > like to edit all my files in MacVim. I can't simply issue an "open -a > MacVim" command since this returns; the call must be a blocking one. > Perhaps one of the scripts (gvim) blocks?
or similar, using the mvim script included with MacVim. It will open a Vim instance (MacVim window) but remain in the foreground (block) until that window is closed (and thus the corresponding Vim instance exits).
> Ideally, I would like the call to open the file in a buffer in a new > tab in an existing window of MacVim, and to return once I've deleted > the buffer. Should this be done with the remote client/server > functionality?
The --remote-tab-wait Vim option is for precisely this, I believe, so something like
> The "Edit in External Editor..." feature is great. I would like to
> have the same functionality from the command line (specifically, from
> my email client, mutt). Can you suggest how this might be done?
> The standard approach is to call Vi in the terminal. However, I would
> like to edit all my files in MacVim. I can't simply issue an "open -a
> MacVim" command since this returns; the call must be a blocking one.
> Perhaps one of the scripts (gvim) blocks?
> Ideally, I would like the call to open the file in a buffer in a new
> tab in an existing window of MacVim, and to return once I've deleted
> the buffer. Should this be done with the remote client/server
> functionality?
> Currently I have this working, through the following route: I call a
> script instead of MacVim. The script creates a lock file, calls
> MacVim, and then waits for the lock file to be removed. When I'm done
> editing the file, I issue a command in Vim that writes the file,
> deletes the buffer and removes the lock file. The script and the
> function are copied below.
> My solution works, but I'm wondering if there's a more direct route --
> one that doesn't write lock files. Any thoughts or comments would be
> appreciated.
> Kudos for doing such a great job with MacVim.
> --Marc
> Script that creates a lock file, calls MacVim, and then waits for the
> lock file to be removed:
> #! /bin/tcsh
> if !(-f $1) touch $1
> touch $1.lck
> open -a MacVim $1
> while (-f $1.lck)
> sleep 0.1
> end
> Vim function that writes the file, deletes the buffer, and then
> removes the lock file:
Somewhere on Shadow Earth, at Tue, Mar 18, 2008 at 06:28:29PM -0700, travis wrote:
> In your .muttrc file just do 'set editor = mvim' > and call MacVim in the terminal by mvim, is that too simple or am I > missing something?
Yes, unfortunately, you are. mutt (and many other Unix-y programs that support an external editor) need the editor to not exit until the edit is done. For example, I use mutt and vim to process my mail, and I have gvim wrapped in a shell script called gvimf, that just does a 'gvim -f "$@"' so that it will stick around until I am done, then return the edited file to mutt to send.
-- Timothy Knox <mailto:t...@thelbane.com> The one thing I've learned about freedom of expression is that you really ought to keep that sort of thing to yourself. -- Scott Adams, _I'm Not Anti-Business, I'm Anti-Idiot_
>> In your .muttrc file just do 'set editor = mvim' >> and call MacVim in the terminal by mvim, is that too simple or am I >> missing something?
> Yes, unfortunately, you are. mutt (and many other Unix-y programs > that support > an external editor) need the editor to not exit until the edit is > done. For > example, I use mutt and vim to process my mail, and I have gvim > wrapped in a > shell script called gvimf, that just does a 'gvim -f "$@"' so that > it will stick > around until I am done, then return the edited file to mutt to send.
set editor ="mvim -f"
should work, shouldn't it? At least `export EDITOR="mvim -f"` works for git and svn.
Nico Weber wrote: >>> In your .muttrc file just do 'set editor = mvim' >>> and call MacVim in the terminal by mvim, is that too simple or am I >>> missing something? >> Yes, unfortunately, you are. mutt (and many other Unix-y programs >> that support >> an external editor) need the editor to not exit until the edit is >> done. For >> example, I use mutt and vim to process my mail, and I have gvim >> wrapped in a >> shell script called gvimf, that just does a 'gvim -f "$@"' so that >> it will stick >> around until I am done, then return the edited file to mutt to send.
> set editor ="mvim -f"
> should work, shouldn't it? At least `export EDITOR="mvim -f"` works > for git and svn.
Yes, I think so. Or
editor="mvim --remote-tab-wait"
I wonder where my earlier post that suggested those two things went.
> Nico Weber wrote:
> >>> In your .muttrc file just do 'set editor = mvim'
> >>> and call MacVim in the terminal by mvim, is that too simple or am I
> >>> missing something?
> >> Yes, unfortunately, you are. mutt (and many other Unix-y programs
> >> that support
> >> an external editor) need the editor to not exit until the edit is
> >> done. For
> >> example, I use mutt and vim to process my mail, and I have gvim
> >> wrapped in a
> >> shell script called gvimf, that just does a 'gvim -f "$@"' so that
> >> it will stick
> >> around until I am done, then return the edited file to mutt to send.
> > set editor ="mvim -f"
> > should work, shouldn't it? At least `export EDITOR="mvim -f"` works
> > for git and svn.
> Yes, I think so. Or
> editor="mvim --remote-tab-wait"
> I wonder where my earlier post that suggested those two things went.