Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
"Edit in External Editor..." feature from the command line (or from mutt)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Cyclify  
View profile  
 More options Mar 18 2008, 7:37 pm
From: Cyclify <mrie...@umn.edu>
Date: Tue, 18 Mar 2008 16:37:23 -0700 (PDT)
Local: Tues, Mar 18 2008 7:37 pm
Subject: "Edit in External Editor..." feature from the command line (or from mutt)
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:

function! <SID>WriteDeleteUnlock()
   let l:lockfile = expand("%:p").'.lck'
   write
   execute("bdelete")
   call system("rm -f ".l:lockfile)
endfunction


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Schmidt  
View profile  
 More options Mar 18 2008, 8:36 pm
From: Ben Schmidt <mail_ben_schm...@yahoo.com.au>
Date: Wed, 19 Mar 2008 11:36:53 +1100
Local: Tues, Mar 18 2008 8:36 pm
Subject: Re: "Edit in External Editor..." feature from the command line (or from mutt)

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?

I think you should be able to do

/Applications/MacVim.app/Contents/MacOS/Vim -f "$1"

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

/Applications/MacVim.app/Contents/MacOS/Vim --remote-tab-wait "$1"

or with the mvim script.

See :help --remote-tab-wait

Ben.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
travis  
View profile  
 More options Mar 18 2008, 9:28 pm
From: travis <eatsleepg...@gmail.com>
Date: Tue, 18 Mar 2008 18:28:29 -0700 (PDT)
Local: Tues, Mar 18 2008 9:28 pm
Subject: Re: "Edit in External Editor..." feature from the command line (or from mutt)
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?

On Mar 18, 7:37 pm, Cyclify <mrie...@umn.edu> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Timothy Knox  
View profile  
 More options Mar 18 2008, 9:32 pm
From: Timothy Knox <t...@thelbane.com>
Date: Tue, 18 Mar 2008 17:32:49 -0800
Local: Tues, Mar 18 2008 9:32 pm
Subject: Re: "Edit in External Editor..." feature from the command line (or from mutt)
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_


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nico Weber  
View profile  
 More options Mar 19 2008, 2:55 am
From: Nico Weber <nicolaswe...@gmx.de>
Date: Wed, 19 Mar 2008 07:55:09 +0100
Local: Wed, Mar 19 2008 2:55 am
Subject: Re: "Edit in External Editor..." feature from the command line (or from mutt)

>> 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Schmidt  
View profile  
 More options Mar 19 2008, 9:35 am
From: Ben Schmidt <mail_ben_schm...@yahoo.com.au>
Date: Thu, 20 Mar 2008 00:35:27 +1100
Local: Wed, Mar 19 2008 9:35 am
Subject: Re: "Edit in External Editor..." feature from the command line (or from mutt)

Yes, I think so. Or

editor="mvim --remote-tab-wait"

I wonder where my earlier post that suggested those two things went.

Ben.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cyclify  
View profile  
 More options Mar 19 2008, 5:23 pm
From: Cyclify <mrie...@umn.edu>
Date: Wed, 19 Mar 2008 14:23:53 -0700 (PDT)
Local: Wed, Mar 19 2008 5:23 pm
Subject: Re: "Edit in External Editor..." feature from the command line (or from mutt)
Ben and Nico,

Thanks for your reply!

"mvim --remote-tab-wait" is exactly the functionality that I need.

--Marc

On Mar 19, 8:35 am, Ben Schmidt <mail_ben_schm...@yahoo.com.au> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John_108  
View profile  
 More options Apr 13 2012, 12:27 pm
From: John_108 <jgl...@gmail.com>
Date: Fri, 13 Apr 2012 09:27:17 -0700 (PDT)
Local: Fri, Apr 13 2012 12:27 pm
Subject: Re: "Edit in External Editor..." feature from the command line (or from mutt)

This worked great for me:

>      set editor ="mvim -f"

except that after writing the file and closing MacVim, I had to switch back to the terminal to get back to mutt.

In the current MacVim version 7.3.390 (and maybe for much longer) the solution is found in "help: hints":

 mvim -f -c "au VimLeave * maca hide:

Works like a charm. When I start to compose in Mutt, MacVim opens, and when I finish the focus returns to mutt automatically.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »