Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this strange problem with using vi as the editor for git commit -a.

Normal flow is: I type git commit -a, vi appears, I enter my commit message, and then :wq to save & exit from vi.

This works fine. However, sometimes I make a typo and instead of :wq I type :Wq (because I use the shift for :). Then, when I correct myself and type :wq again, git gives the following error:

error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.

How can I fix this?

share|improve this question
What version of git and vi? I can't repro this with vim 7.3, git version – Christopher Jul 26 '12 at 22:00
@Christopher : vi 7.3 and git (Apple Git-31.1), the default ones on Mountain Lion afaik – houbysoft Jul 26 '12 at 23:07
up vote 14 down vote accepted

vi is existing with a non-zero status, although without additional details about your setup, it's difficult to tell why. If you're using a lot of plugins to vim, you might try moving your .vimrc file to .vimrc.back and seeing if you can replicate. There are a few sources that discuss this problem, including at least one with a potential solution:

git config --global core.editor /usr/bin/vim

I would try removing your .vimrc first, however. It seems to cause more consternation.

share|improve this answer
Thanks, git config --global core.editor /usr/bin/vim fixed it. – houbysoft Jul 27 '12 at 13:04

As answered here:

The real solution is to

git config --global core.editor vim -f

According to vim documentation - -f option should be used when Vim is executed by a program that will wait for the edit session to finish

share|improve this answer
Finally... this is the right solution. It also fixes the problem of hitting :W and having git reject your commit message when you subsequently save it. – Ryanmt Nov 6 '14 at 22:23

Do you use the golang vim plugins? This line is causing the vi exit value problem for me: filetype plugin indent off

Removing the whole golang plugin block in .vimrc fixed the problem. Installing the golang plugin using fugitive can be as easy as: ln -s $GOROOT/misc/vim ~/.vim/bundle/vim-golang

(I just documented the problem in this issue on the vim-golang github)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.