Quiz Entry - updated: 2026.07.14
How do you save and quit in VIM?
:w saves, :q quits, :wq does both, and :q! quits throwing away unsaved changes.
In Normal mode, press : to drop into Command mode, then type the letters and Enter. The pieces compose: w=write, q=quit, !=force.
Essential command mode commands (press : first):
| Command | Action |
|---|---|
:w |
Write (save) file |
:q |
Quit (exit) |
:wq |
Write and quit |
:q! |
Quit without saving (force) |
:wq! |
Write and quit (force) |
Examples:
:w " Save changes
:q " Exit (fails if unsaved changes)
:wq " Save and exit
:q! " Exit without saving
:w newfile.txt " Save as different filename
Mnemonic:
w= writeq= quit!= force (override warnings)