How do you quit Vim without saving?
: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.
Related Vim shortcuts: File Operations
| Shortcut | Action | Notes |
|---|---|---|
| :w | Save | Save file |
| :q | Quit | Quit Vim |
| :wq | Save & Quit | Save and quit |
| :q! | Force Quit | Quit without saving |
| :e filename | Edit File | Open file for editing |
| :sp | Split Horizontal | Split window horizontally |
| :vsp | Split Vertical | Split window vertically |
From the Vim reference (57 entries) · all how-to answers