Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete multiple buffers in Vim?

Tags:

vim

buffer

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?

like image 327
Thanh DK Avatar asked Jul 01 '10 06:07

Thanh DK


People also ask

How do I delete a buffer in Vim?

Assuming the default backslash leader key, you can also press \bd to close (delete) the buffer in the current window (same as :Bclose ).

How do I delete a buffer?

Permanently deleting your Buffer accountClick on your profile avatar at the top right of your dashboard and then click Account from the drop down menu. Click Delete My Buffer Account towards the bottom of the page. Enter your password and click Confirm.

How do I delete all in Vim?

To delete all line you can use either the % symbol that represents all lines or the 1,$ range: Press the Esc key to go to normal mode. Type %d and hit Enter to delete all the lines.


2 Answers

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.

like image 108
Björn Steinbrink Avatar answered Oct 22 '22 15:10

Björn Steinbrink


:3,5bd[elete]    

Will delete buffer range from 3 to 5 .

like image 43
Fisherman Avatar answered Oct 22 '22 14:10

Fisherman