File Operations in Vim
From the Vim cheat sheet · Files & Buffers · verified Jul 2026
File Operations
Opening, saving, and managing files
text
:e filename - Edit/open file
:w - Save current file
:w filename - Save as filename
:wq or :x - Save and quit
:q - Quit
:q! - Quit without saving
:qa - Quit all windows
:wqa - Save and quit all
:r filename - Read file into current buffer
:r !command - Read command output into buffer
:bn - Next buffer
:bp - Previous buffer
:bd - Delete buffer (close file)
:ls or :buffers - List all buffers
:b# - Switch to alternate buffer
:b name - Switch to buffer by name/number💡 Use :w to save frequently
⚡ :x is shorthand for :wq
📌 :q! forces quit without saving
🟢 Remember :w (save) and :q (quit)
filesbuffers