gpt4 book ai didi

vim - 如何关闭 vim 窗口中未显示的所有缓冲区?

转载 作者:行者123 更新时间:2023-12-02 20:27:01 25 4
gpt4 key购买 nike

我在 vim 中打开了一大堆缓冲区,其中只有少数在拆分窗口或其他选项卡上打开。有没有办法关闭除当前在这些拆分或选项卡之一中可见的那些之外的所有内容?

最佳答案

对此的另一种看法。使用 Vim 帮助中给定的 tabpagebuflist() 示例来获取选项卡或窗口中出现的缓冲区列表。我的 .vimrc

中有以下内容
function! DeleteInactiveBufs()
"From tabpagebuflist() help, get a list of all buffers in all tabs
let tablist = []
for i in range(tabpagenr('$'))
call extend(tablist, tabpagebuflist(i + 1))
endfor

"Below originally inspired by Hara Krishna Dara and Keith Roberts
"http://tech.groups.yahoo.com/group/vim/message/56425
let nWipeouts = 0
for i in range(1, bufnr('$'))
if bufexists(i) && !getbufvar(i,"&mod") && index(tablist, i) == -1
"bufno exists AND isn't modified AND isn't in the list of buffers open in windows and tabs
silent exec 'bwipeout' i
let nWipeouts = nWipeouts + 1
endif
endfor
echomsg nWipeouts . ' buffer(s) wiped out'
endfunction
command! Bdi :call DeleteInactiveBufs()

关于vim - 如何关闭 vim 窗口中未显示的所有缓冲区?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1534835/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com