开发者

MacVim and Mercurial check-in

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 whe开发者_运维百科n 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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜