How do I quit Vim without saving using a two-keystroke normal mode shortcut?
Answer
ZQ
Explanation
ZQ is the discard-and-quit counterpart to ZZ. While ZZ writes the file and exits (equivalent to :wq), ZQ exits immediately without saving, even if the buffer has unsaved changes — equivalent to :q!.
How it works
ZZ— write buffer and quit (:wq)ZQ— quit without writing, discarding any changes (:q!)- Both work from normal mode only and apply to the current window/tab
- If there are multiple windows open,
ZQcloses only the current window (like:q!) - If it is the last window, Vim exits entirely
Example
You open a file to inspect it, accidentally make a change, and want to exit cleanly:
" Instead of typing:
:q!<CR>
" Just press (in normal mode):
ZQ
Tips
- Unlike
:q!,ZQrequires no colon and no Enter — it is faster to type under urgency ZQis mnemonic: think of it as "Z-Quit" (the nuclear option next to the save shortcutZZ)- To close all windows and quit without saving everything, use
:qa!instead —ZQonly affects the current window