How do you quit Vim without saving?

Vim · File Operations · updated 2026-08-23

:q! — Force Quit

Press Esc to leave insert mode, type :q! and press Enter. The exclamation mark discards unsaved changes; :wq saves and quits, and :q alone refuses to quit while the buffer is modified.

The reason :q alone refuses is Vim protecting a modified buffer - it will print E37: No write since last change. If you got into Vim by accident (a git commit opened it, or you typed vi instead of vim on a file you meant to cat), :q! is the exit that never argues back.

Two related exits worth knowing: ZZ in normal mode saves and quits like :wq but with two keystrokes, and ZQ quits without saving like :q!. If the terminal seems frozen rather than stuck in Vim, you may have pressed Ctrl + S (terminal scroll lock) - Ctrl + Q resumes it.

Related Vim shortcuts: File Operations

ShortcutActionNotes
:wSaveSave file
:qQuitQuit Vim
:wqSave & QuitSave and quit
:q!Force QuitQuit without saving
:e filenameEdit FileOpen file for editing
:spSplit HorizontalSplit window horizontally
:vspSplit VerticalSplit window vertically

From the Vim reference (57 entries) · all how-to answers

Why :q refuses

Vim protects unsaved edits: :q exits only if the buffer is unmodified, and otherwise prints E37, "No write since last change". The bang in :q! overrides that check and discards the changes. If you want them, :wq or :x writes and quits, and :w newname saves to a different file when the original is read-only. With several files open, :qa! quits all of them.

Getting to the command line

Commands starting with a colon work only in Normal mode. If the screen shows -- INSERT -- or -- VISUAL -- at the bottom, press Esc first; if a previous keystroke left Vim waiting (a pending count or a half-typed command), press Esc twice. When the terminal itself seems frozen, Ctrl + Q releases a Ctrl + S flow-control pause that is easy to trigger by accident.

Recovering after a bad quit

If the terminal died rather than Vim quitting cleanly, Vim leaves a swap file next to the edited one; reopening the file offers to recover from it. :recover does the same by hand, and deleting the .swp file removes the prompt once the recovery is done.