Cheatsheet Pages / Vim Cheatsheet
How to quit Vim and throw your changes away — :q! and ZQ
The buffer is a mess and the file on disk is the version you trust — you want out, discarding everything.
Almost every entry was run headless in Vim 9.1 and the resulting file checked; the few entries a tiny build cannot run (system clipboard, persistent undo, the sudo save) were verified against Vim's own documentation instead.
:q! " quit WITHOUT saving — unsaved changes are discarded
ZQ " normal-mode twin of :q!
Good to know
⚠️ There is no undo after :q! / ZQ — the edits never reached the disk, so they are gone. Use it when the buffer is a mess and the file on disk is the version you trust.
