8

I'm trying to use MacVim as a default editor (on my Mac, obviously). I'd like to have MacVim to edit commit messages when I hg ci. Unfortunately when I do so (either by setting EDITOR=mvim or alias vi='mvim') MacVim pops up with an empty message (i.e. none of the boilerplate in the bottom half), and when I save that commit message I get the error "abort: empty commit message".

Is there a way to use MacVim (presumably via mvim) to edit the commit messages when checking in changes with Mercurial?

Thank you for reading, and I look forward to reading the answers.

Brian

4
  • are you setting that in ur hgrc or just env variable? Commented Oct 28, 2010 at 18:16
  • Note that aliases are internal to the shell; programs run by the shell can't access them. Commented Oct 29, 2010 at 1:22
  • @Roger Pate: I figured that, but it was worth a shot! :) Commented Oct 29, 2010 at 2:27
  • I have the exact same problem...except on windows with cygwin and gvim! Thanks for asking this... Commented Mar 2, 2011 at 10:14

2 Answers 2

11

Set EDITOR='mvim -f', per the tip from the FAQ for making it work with Git:

How can I use MacVim to edit Git commit messages?

Add the following line to the file ~/.profile:

export EDITOR='mvim -f -c "au VimLeave * !open -a Terminal"' 

The last part ensures that Terminal gets focus again after closing the commit message. (Note that you need to put the mvim script in your path for this to work.)

Sign up to request clarification or add additional context in comments.

4 Comments

So the answer was really to use Git. Clearly it has the superior FAQ. hehe.
Incidentally, the export EDITOR='...' expands to mvim -f -c "au VimLeave Desktop Documents Downloads Library Movies Music Pictures Public Sites bin !open -a Terminal". I'm not sure if that's the anticipated/desired behaviour. I added set -f to the script right before the export to prevent the glob.
@Roger Pate: I agree, it seems quite weird. I've started a new question to see if the answer can be rooted out: stackoverflow.com/questions/4052593/…
@Brian: I forgot there was an important third option: I'm misunderstanding what's happening and tested with what I thought was equivalent, but wasn't. Deleting those comments.
0

If you have multiple SCMs on a machine (e.g. you have to work with Subversion and Mercurial, as I do), you can differentiate the editor by using HGEDITOR instead of the more generic EDITOR env. For example, I have the following environment variables set up:

export HGEDITOR='mvim -f -c "au VimLeave * !open -a Terminal"' export SVN_EDITOR='mvim -f -c "au VimLeave * !open -a Terminal"' 

In this case it's sort of pointless because the configuration is the same, but this is just to illustrate the point.

That also of course raises the point that you can set EDITOR and get that as the default for your various applications that use that, then override it with an application-specific variable for those apps that need something different. I tend to use the app-specific variables just to be... thorough, I guess (some might call it something else :).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.