How to have a different buffer list for each tabs in Vim?

后端 未结 1 1485
暗喜
暗喜 2021-02-10 13:03

Is it possible to kind of \"attach\" a list of buffers to particular tabs within Vim? I am currently using MiniBufferExplorer, which shows all buffers in nice tabs. It can be co

相关标签:
1条回答
  • 2021-02-10 13:20

    I cant think of any Tab based buffer explorers out there but vimscript has got plenty of functions to track of buffers (:he function-list) . I just knocked this up for the hell of it. It might get you to what you want . It just keeps track of tabs in a vim dictionary. You will need to flesh out the :TabExplorer function or patch the filtered list (ie. g:TabExplorer[tabpagenr()]) into the minibuf plugin

    Save it as ~/.vim/plugin/tabexplorer.vim and source it at startup.

    let g:TabExplorer = {}
    
    func! StoreBufTab()
        if !has_key(g:TabExplorer, tabpagenr())
            let  g:TabExplorer[tabpagenr()] = []
        endif
    
        if index(g:TabExplorer[tabpagenr()], bufname("%")) == -1 && bufname("%") != ""
            call add (g:TabExplorer[tabpagenr()],bufname("%"))
        endif
    endfunc
    
    func! DisplayTabExplorer()
        4split
        enew
        call append(".",g:TabExplorer[tabpagenr()])
    endfunc
    
    au BufEnter * call StoreBufTab()
    
    command! TabExplorer call DisplayTabExplorer()
    
    0 讨论(0)
提交回复
热议问题