vimtricks.wiki Concise Vim tricks, one at a time.

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, ZQ closes 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!, ZQ requires no colon and no Enter — it is faster to type under urgency
  • ZQ is mnemonic: think of it as "Z-Quit" (the nuclear option next to the save shortcut ZZ)
  • To close all windows and quit without saving everything, use :qa! instead — ZQ only affects the current window

Next

How do I make Vim preserve the cursor column when jumping between lines?