The most famous stack-overflow question in history has a three-keystroke answer. The reason it stumps people: vim is modal — if you're in insert mode, ex commands are just text. Esc first, always.
| Keys | What it does |
|---|---|
| :q | quit (fails if there are unsaved changes — that's a feature) |
| :q! | quit and discard changes |
| :wq | write (save) and quit |
| :x | save and quit, but only writes if changed |
| ZZ | save and quit — no colon needed |
| ZQ | quit without saving — no colon needed |
| :qa | quit all open windows |
Reading about keystrokes doesn't build keystrokes. Try this in a real vim buffer right now — the “The stray key” mission takes about a minute.
Practice free — no signup →