MacOS – error: There was a problem with the editor ‘vi’ when using it with git

gitmacosterminalvi

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?

Best Answer

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.