V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
flyaway
V2EX  ›  问与答

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

  •  
  •   flyaway · Dec 22, 2014 · 7740 views
    This topic created in 4148 days ago, the information mentioned may be changed or developed.
    我常用的插件主要VOom、NERDTree、airline,如何实现在退出时,自动关闭这些插件的窗口,现在每次都是要q好几次……
    9 replies    2020-08-07 18:24:40 +08:00
    Tonni
        1
    Tonni  
       Dec 22, 2014   ❤️ 1
    :qall!
    flyaway
        2
    flyaway  
    OP
       Dec 22, 2014
    @Tonni
    :qa会退出所有窗口,我希望的是只剩下一个编辑窗口的情况下,退出时关闭所有buffer窗口。
    whatot
        3
    whatot  
       Dec 22, 2014
    @flyaway 我觉得使用tab更适合你的需求 :help tabpage
    flyaway
        4
    flyaway  
    OP
       Dec 22, 2014
    @whatot 我尝试一下~
    ensonmj
        5
    ensonmj  
       Dec 22, 2014
    :only
    river1007
        6
    river1007  
       Dec 23, 2014
    关闭所有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
        7
    qiqiboy  
       Sep 15, 2017
    au bufenter * if 0 == len(filter(range(1, winnr('$')), 'empty(getbufvar(winbufnr(v:val), "&bt"))')) | qa! | endif
    Lenic
        8
    Lenic  
       Aug 7, 2020
    " 关闭全部 Buffer 但保留当前窗口
    command CloseAllBuffers :bp | bd
    nnoremap <Leader>fq :CloseAllBuffers<CR>
    Lenic
        9
    Lenic  
       Aug 7, 2020
    " 关闭全部 Buffer 但保留当前窗口
    command CloseAllBuffers :bd %
    nnoremap <Leader>fq :CloseAllBuffers<CR>
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1003 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 18:14 · PVG 02:14 · LAX 11:14 · JFK 14:14
    ♥ Do have faith in what you're doing.