How to delete multiple buffers in Vim?

后端 未结 8 1324
北恋
北恋 2021-01-29 18:51

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 w

相关标签:
8条回答
  • 2021-01-29 19:46

    Very simply: use the :bd[elete] command. For example, :bd[elete] buf#1 buf#5 buf#3 will delete the buffers 1, 3, and 5.

    0 讨论(0)
  • 2021-01-29 19:47

    TAB will only autocomplete one file for you as of Vim 7.4.282
    use <c-a> to autocomplete all files.

    You can just use:

    bd filetype
    

    then just use <c-a> to facilitate the completion of all open files of specified filetype.

    for example, you have 1.xml, 2.xml, 3.xml, and 4.xml, you can do:

    bd xml
    

    then press <c-a>

    vim will autocomplete for you as follow:

    bd 1.xml 2.xml 3.xml 4.xml
    

    you can just press enter to complete the command.

    if you have made changes in one of the files mentioned above, do remember to do:

    bd! xml
    
    0 讨论(0)
提交回复
热议问题