Vim: Close All Buffers But This One

前端 未结 13 2358
别那么骄傲
别那么骄傲 2020-12-22 15:04

How can I close all buffers in Vim except the one I am currently editing?

13条回答
  •  佛祖请我去吃肉
    2020-12-22 15:56

    I do this

    :w | %bd | e#
    

    My favorite if I just want my current buffer open and close all others.

    How it works: first write current buffer's changes, then close all open buffers, then reopen the buffer I was currently on. In Vim, the | chains the execution of commands together. If your buffer is up to date the above can be shortened to :%bd | e#

提交回复
热议问题