Cheatsheet Pages / Vim Cheatsheet

How to save and quit in Vim — :w, :q, :wq and ZZ

The first survival skill: saving your work, quitting, or doing both — without fear of the unsaved-changes refusal.

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.

:w          " write (save) the file, stay in Vim
:q          " quit — Vim refuses if there are unsaved changes
:wq         " write AND quit
ZZ          " normal-mode twin of :wq — but like :x, it only writes if modified
Vim Cheatsheet one-page card — commands that actually work
The full one-page card — Vim Cheatsheet. Get the complete cheatsheet on GitHub