How to delete multiple buffers in Vim?

Thanh DK picture Thanh DK · Jul 1, 2010 · Viewed 17.8k times · Source

Assuming I have multiple files opened as buffers in Vim. The files have *.cpp, *.h and some are *.xml. I want to close all the XML files with :bd *.xml. However, Vim does not allow this (E93: More than one match...).

Is there any way to do this?

P.S. I know that :bd file1 file2 file3 works. So can I somehow evaluate *.xml to file1.xml file2.xml file3.xml?

Answer

Björn Steinbrink picture Björn Steinbrink · Feb 29, 2012

You can use <C-a> to complete all matches. So if you type :bd *.xml and then hit <C-a>, vim will complete the command to :bd file1.xml file2.xml file3.xml.