46

This is what I have in my ~/.bashrc

export GIT_EDITOR='/Applications/MacVim.app/Contents/MacOS/Vim -g '

When I issue

git commit

then I get a macvim editor but on the command line I see this message

$ git commit
Aborting commit due to empty commit message.

If I use change GIT_EDITOR to use textmate then things work fine

export GIT_EDITOR='/usr/local/bin/mate -w'

I don't want to use textmate. I want to use macvim. I am using mac and use bash.

4 Answers 4

69

You need to supply the -f option to vim to ensure that it doesn't background itself.

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

1 Comment

This no longer works in --patch mode. If you edit a hunk, it opens properly. When you :wq from Macvim the hunk is edited and --patch moves on to the next hunk, but then immediately quits with suspended (tty input) git add -p. Any ideas?
38

I had the same problem. I fixed it by setting mvim as the default editor for git by running the following from the command line:

git config --global core.editor "mvim -f"

Comments

12

This worked great for me.
git config --global core.editor 'mvim -f --nomru -c "au VimLeave * !open -a iTerm"'
If you are using Terminal.app instead of iTerm.app you can just switch it out. Source: https://github.com/b4winckler/macvim/wiki/FAQ (though they are using the EDITOR env variable instead of the gitconfig)

4 Comments

Is there a way to make this work if there are already other Vim windows open?
Did you try it with other windows open? It should not have any negative effects. What problem are you having?
I am unable to get this working, I understand what it should do but I get this error: warning: core.editor has multiple values error: cannot overwrite multiple values with a single value Use a regexp, --add or --replace-all to change core.editor Could you help me out here please?
Well, I got it working by placing this to my ~/.zshrc export GIT_EDITOR='mvim -f --nomru -c "au VimLeave * !open -a iTerm.app"'
0

I had a similar problem. Adding the --noplungin flag to vim solved it for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.