Problems with entering Git commit message with Vim

aTei picture aTei · Apr 8, 2011 · Viewed 146.3k times · Source

OS: Windows

I write

$ git commit

then

"# Please enter the commit message"

I write some text, like

"Form validation added"

Press Enter and not commited. Then i press Shift+Enter, Ctrl+Enter, Alt+Enter - still not commited.

I think its stupid trouble, but What i must to do?

Answer

mousio picture mousio · Apr 8, 2011

If it is VIM for Windows, you can do the following:

  • enter your message following the presented guidelines
  • press Esc to make sure you are out of the insert mode
  • then type :wqEnter or ZZ.

Note that in VIM there are often several ways to do one thing. Here there is a slight difference though. :wqEnter always writes the current file before closing it, while ZZ, :xEnter, :xiEnter, :xitEnter, :exiEnter and :exitEnter only write it if the document is modified.
All these synonyms just have different numbers of keypresses.