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

2014-12-22 21:20:19 +08:00
 flyaway
我常用的插件主要VOom、NERDTree、airline,如何实现在退出时,自动关闭这些插件的窗口,现在每次都是要q好几次……
6952 次点击
所在节点    问与答
9 条回复
Tonni
2014-12-22 21:34:53 +08:00
:qall!
flyaway
2014-12-22 21:40:37 +08:00
@Tonni
:qa会退出所有窗口,我希望的是只剩下一个编辑窗口的情况下,退出时关闭所有buffer窗口。
whatot
2014-12-22 21:46:45 +08:00
@flyaway 我觉得使用tab更适合你的需求 :help tabpage
flyaway
2014-12-22 21:51:37 +08:00
@whatot 我尝试一下~
ensonmj
2014-12-22 22:36:34 +08:00
:only
river1007
2014-12-23 14:28:17 +08:00
关闭所有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-09-15 11:06:06 +08:00
au bufenter * if 0 == len(filter(range(1, winnr('$')), 'empty(getbufvar(winbufnr(v:val), "&bt"))')) | qa! | endif
Lenic
2020-08-07 13:33:15 +08:00
" 关闭全部 Buffer 但保留当前窗口
command CloseAllBuffers :bp | bd
nnoremap <Leader>fq :CloseAllBuffers<CR>
Lenic
2020-08-07 18:24:40 +08:00
" 关闭全部 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