Save changes and close the window
ZZ
Example
Normal mode. Unsaved edits in writable draft.txt. No other modified buffers or unvisited argument-list files.
Before
Current window: draft.txt
Buffer: unsaved changes
- ZZ Save and close this window · final window exits when quit checks succeed
After
draft.txt: saved
Current window: closed
Details & Vim help
Write the current buffer if modified, then close the current window.
Finish a file with two Normal-mode keystrokes.
Write errors, other unsaved buffers or unvisited argument-list files can prevent quitting. With other windows open Vim continues running. ZZ corresponds to :x; ZQ closes without saving.
If other windows remain, Vim keeps running. Writing or quit checks can prevent the window from closing.
Try it in Vim
- Press uppercase Z twice in Normal mode.
- If the buffer is modified, Vim attempts to write it.
- The current window closes if writing, when needed, and the quit checks succeed.