How do I completely remove a buffer from Vim?
Answer
:bwipeout
Explanation
The :bwipeout command (:bw) completely removes a buffer from Vim's memory, including its marks, options, and variables. It is more thorough than :bdelete.
How it works
:bwipeoutremoves the current buffer entirely:bw 3wipes buffer number 3- The buffer is removed from the buffer list
- All associated data is freed
Example
:ls " List buffers
:bw 5 " Completely remove buffer 5
:bw! " Force wipe even with unsaved changes
Tips
:bdeletehides the buffer but keeps it in memory (unlisted):bwipeouttruly removes everything- Use
:bwwhen you want to clean up buffer numbers :bdis usually sufficient for normal use- Be careful with
:bw!— unsaved changes are lost permanently