vimtricks.wiki Concise Vim tricks, one at a time.

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

  • :bwipeout removes the current buffer entirely
  • :bw 3 wipes 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

  • :bdelete hides the buffer but keeps it in memory (unlisted)
  • :bwipeout truly removes everything
  • Use :bw when you want to clean up buffer numbers
  • :bd is usually sufficient for normal use
  • Be careful with :bw! — unsaved changes are lost permanently

Next

How do you yank a single word into a named register?