V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
flyaway
V2EX  ›  问与答

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

  •  
  •   flyaway · 2014 年 12 月 22 日 · 7610 次点击
    这是一个创建于 4060 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我常用的插件主要VOom、NERDTree、airline,如何实现在退出时,自动关闭这些插件的窗口,现在每次都是要q好几次……
    9 条回复    2020-08-07 18:24:40 +08:00
    Tonni
        1
    Tonni  
       2014 年 12 月 22 日   ❤️ 1
    :qall!
    flyaway
        2
    flyaway  
    OP
       2014 年 12 月 22 日
    @Tonni
    :qa会退出所有窗口,我希望的是只剩下一个编辑窗口的情况下,退出时关闭所有buffer窗口。
    whatot
        3
    whatot  
       2014 年 12 月 22 日
    @flyaway 我觉得使用tab更适合你的需求 :help tabpage
    flyaway
        4
    flyaway  
    OP
       2014 年 12 月 22 日
    @whatot 我尝试一下~
    ensonmj
        5
    ensonmj  
       2014 年 12 月 22 日
    :only
    river1007
        6
    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
        7
    qiqiboy  
       2017 年 9 月 15 日
    au bufenter * if 0 == len(filter(range(1, winnr('$')), 'empty(getbufvar(winbufnr(v:val), "&bt"))')) | qa! | endif
    Lenic
        8
    Lenic  
       2020 年 8 月 7 日
    " 关闭全部 Buffer 但保留当前窗口
    command CloseAllBuffers :bp | bd
    nnoremap <Leader>fq :CloseAllBuffers<CR>
    Lenic
        9
    Lenic  
       2020 年 8 月 7 日
    " 关闭全部 Buffer 但保留当前窗口
    command CloseAllBuffers :bd %
    nnoremap <Leader>fq :CloseAllBuffers<CR>
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   2456 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 12:32 · PVG 20:32 · LAX 04:32 · JFK 07:32
    ♥ Do have faith in what you're doing.