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

Brian M. Hunt
  • 81,008
  • 74
  • 230
  • 343

2 Answers2

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

Community
  • 1
  • 1
Jeremy W. Sherman
  • 35,901
  • 5
  • 77
  • 111
  • So the answer was really to use Git. Clearly it has the superior FAQ. hehe. – Brian M. Hunt Oct 28 '10 at 18:34
  • 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. – Brian M. Hunt Oct 28 '10 at 18:43
  • 1
    @Roger Pate: I agree, it seems quite weird. I've started a new question to see if the answer can be rooted out: http://stackoverflow.com/questions/4052593/mac-os-x-bash-default-pathname-expansion-or-bug – Brian M. Hunt Oct 29 '10 at 14:06
  • @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. –  Oct 29 '10 at 15:07
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 :).

Spanky Quigman
  • 870
  • 7
  • 16