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

给你一囗甜甜゛ 提交于 2019-12-03 08:28:05

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()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!