Vim 求问,退出时关闭所有 buffer 窗口

2014 年 12 月 22 日
 flyaway
我常用的插件主要VOom、NERDTree、airline,如何实现在退出时,自动关闭这些插件的窗口,现在每次都是要q好几次……
8128 次点击
所在节点    问与答
9 条回复
Tonni
2014 年 12 月 22 日
:qall!
flyaway
2014 年 12 月 22 日
@Tonni
:qa会退出所有窗口,我希望的是只剩下一个编辑窗口的情况下,退出时关闭所有buffer窗口。
whatot
2014 年 12 月 22 日
@flyaway 我觉得使用tab更适合你的需求 :help tabpage
flyaway
2014 年 12 月 22 日
@whatot 我尝试一下~
ensonmj
2014 年 12 月 22 日
:only
river1007
2014 年 12 月 23 日
关闭所有buffer,除了当前编辑的buffer

function! DeleteAllBuffersInWindow()
let s:curWinNr = winnr()
if winbufnr(s:curWinNr) == 1
ret
endif
let s:curBufNr = bufnr("%")
exe "bn"
let s:nextBufNr = bufnr("%")
while s:nextBufNr != s:curBufNr
exe "bn"
exe "bdel ".s:nextBufNr
let s:nextBufNr = bufnr("%")
endwhile
endfun
noremap <leader>dab :call DeleteAllBuffersInWindow()<CR>
qiqiboy
2017 年 9 月 15 日
au bufenter * if 0 == len(filter(range(1, winnr('$')), 'empty(getbufvar(winbufnr(v:val), "&bt"))')) | qa! | endif
Lenic
2020 年 8 月 7 日
" 关闭全部 Buffer 但保留当前窗口
command CloseAllBuffers :bp | bd
nnoremap <Leader>fq :CloseAllBuffers<CR>
Lenic
2020 年 8 月 7 日
" 关闭全部 Buffer 但保留当前窗口
command CloseAllBuffers :bd %
nnoremap <Leader>fq :CloseAllBuffers<CR>

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/155848

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX