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

1

6

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 combined using standard vim tabs but the plugin's buffer list contains all the buffers and using tabs become a bit useless. Here's an example of what I'd like:

Tab A contains a buffer list of:

  • FileA
  • FileB
  • FileC

Tab B contains a buffer list of:

  • FileD
  • FileE
  • FileF

Currently what I have is this:

Tab A contains a buffer list of

  • FileA
  • FileB
  • FileC
  • FileD
  • FileE
  • FileF

Tab B contains a buffer list of:

  • FileA
  • FileB
  • FileC
  • FileD
  • FileE
  • FileF

When speaking about "buffer list" I mean the tab listing the minibuffer plugin gives.

Any workaround to achieve this?

Rehm answered 22/2, 2010 at 1:25 Comment(1)
I'm also looking for a similar setup. NERDTree + MiniBufferExplorer + tabs would be a nice way to have multiple projects in one physical window. The code in the answer below looks to be a good start.Ondrej
B
6

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()
Brusa answered 22/2, 2010 at 2:45 Comment(1)
@Brusa Thanks a lot for that jump start. I started using that code until I decided to shift to netbeans and its jvi vim plugin as decribed in another question I posted here: #2276531 .Rehm

© 2022 - 2024 — McMap. All rights reserved.