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.

Nick Vanderbilt
  • 36,724
  • 29
  • 83
  • 106

4 Answers4

69

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

CB Bailey
  • 755,051
  • 104
  • 632
  • 656
  • 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? – Bailey Parker Aug 10 '15 at 00:20
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"
9monkeys
  • 1,754
  • 1
  • 14
  • 13
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)

mraaroncruz
  • 3,780
  • 2
  • 32
  • 31
  • Is there a way to make this work if there are already other Vim windows open? – Chris Nov 27 '12 at 18:11
  • Did you try it with other windows open? It should not have any negative effects. What problem are you having? – mraaroncruz Nov 28 '12 at 08:43
  • 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? – Tomas Sykora Apr 08 '18 at 19:00
  • 1
    Well, I got it working by placing this to my ~/.zshrc `export GIT_EDITOR='mvim -f --nomru -c "au VimLeave * !open -a iTerm.app"' ` – Tomas Sykora Apr 08 '18 at 19:08
0

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

Jacob Horbulyk
  • 2,366
  • 5
  • 22
  • 34