error: There was a problem with the editor 'vi' when using it with git 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 &amp; 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?
As answered here:
https://stackoverflow.com/questions/22699614/git-commit-messages-lost-by-vi

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