How can I close a buffer without closing the window?

前端 未结 16 1030
鱼传尺愫
鱼传尺愫 2020-12-12 13:35

Vim\'s multilayered views (Windows, Buffers and Tabs) left me a little confused. Let\'s say I split the display (:sp) and then select a different buffer to display in each w

16条回答
  •  旧时难觅i
    2020-12-12 13:45

    I messed with this a bit and finally came up with:

    :bp | sp | bn | bd
    

    Here's the copy/paste version for key mapping:

    :bpspbnbd
    

    I've tested it a fair bit and it works consistently in various conditions. When used on the last buffer it will leave you with a new blank buffer.

    Throw this in your .vimrc:

    map q :bpspbnbd
    

    Restart Vim, or just :source ~/.vimrc for changes to take effect. Next time you want to close a buffer just type: \q (if \ is your leader key)

提交回复
热议问题