Often when I'm finished writing a commit message in VIM, I type :Wq<ENTER>
instead of :wq<ENTER>
because I'm holding down the shift key to type the colon. This causes VIM to respond with E492: Not an editor command: Wq
.
This is all fine so far, I just retype :wq<ENTER>
to save the commit message and exit VIM. However, the commit does not work then, and the terminal shows something like this:
$ git commit
$ error: There was a problem with the editor 'vi'.
$ Please supply the message using either -m or -F option.
Why does accidentally entering :Wq<ENTER>
before doing the correct :wq<ENTER>
cause the commit to fail? Is there any way to get the commit to happen after entering :Wq<ENTER>
?
This article seems to describe a similar issue.
Looks like when you use the capital 'W' Vim is exiting with an error code when invoked by Git.
Have you tried:
git config --global core.editor /usr/bin/vim
(or wherever you have vim installed on your system)...which seemed to clear up the issue. Must be related to how how Git invokes Vim.
Also, see this question which indicates that it may have to do with the filetype
setting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With