Vim: Quit with an error code (eg. to prevent Git from committing)
If you want to prevent Git from committing after editing the commit message, do:
:cq
This will make Vim to quit with an error code, preventing the commit operation from proceed.
Written by Caio Ariede
Related protips
5 Responses

Nice. Suggested mnemonic, "cancel-y quit"... "commit quitter"...
I've just had been leaving an empty commit message; git then cancels the commit.
over 1 year ago
·

Brevity is the soul of vim. :-) Great tip.
@alxndr: "Call-it quits", maybe?
over 1 year ago
·

You can also quit without writing to avoid a commit. This command is nice because it's useful in lots of situations.
:q!
over 1 year ago
·

Caution: your changes won't be saved by :cq
over 1 year ago
·

Watch out! If you're doing a git commit --amend
, then you need :cq
, otherwise you'll regenerate the commit with the same message (if you already pushed... d'oh).
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#