Vim - dynamic list of open buffers in a window

Did you search vim.org's plugin repository? There are dozens of buffer switching plugins for you to choose from like BufferGator or SelectBuf. Alternatively, most of them are compiled in a nice list on the Vim wiki.


As you alluded in the last part of your question that kind of system is not to everyone's taste.

I hate having all those menus, buttons and lists of this or that open at all times: a list of open buffers is only useful when you actually need to jump to another buffer, leaving such a list open seems like a waste of space to me. The same can be applied to supercharged statuslines as well.

I use the same plugin for quicly switching between buffers and quicly exploring the filesystem around the file I'm currently editing. Invoked with ,f (files) or ,b (buffers), the window disappears when I'm done. Perfect. There are other similar plugins, try them all if you like that idea.

EDIT

I feel compelled to add an animated GIF of CtrlP in action, switching buffers:

Switching buffers with CtrlP

ENDEDIT

The native :sb <Tab> is also pretty neat but less sexy. It doesn't support fuzzy matching but it has some big advantages: it's built in and it works like :e <Tab>, :vs <Tab> and so on.


I can highly recommend the MiniBufExplorer. See also an alternative to minibufexplorer?

Screenshot


There a way to do exactly that using winmanager plugin. In this screenshot I combine both NERDTree and MiniBufExpl (github: techlivezheng/vim-plugin-minibufexpl, latest commit atm 349a9fbb) plugins on the same vertical split and toggle it with F4. In theory this solution should work for any other plugins combination.

Example of my .vimrc

" {{{ MiniBufExpl config
let g:miniBufExplVSplit = 20 " open in vertical
let g:miniBufExplSplitToEdge = 0 " open relative to previous window (NERDTree)
" }}} MiniBufExpl config

" {{{ winmanager config
" register the plugins
let g:NERDTree_title='NERD Tree'
let g:MiniBufExpl_title='MiniBufExpl'

" set the layout
let g:winManagerWindowLayout='NERDTree|MiniBufExpl'

" handler for NERDTree
function! NERDTree_Start()
    exec 'NERDTree'
endfunction

" handler for MiniBufExpl
function! MiniBufExpl_Start()
    exec 'MBEOpen'
endfunction

" mapping to toggle the split to F4
nmap <F4> :WMToggle
" }}} winmanager config

Problems:

  • NERDTree doesn't use the buffer that winmanager creates but opens in its own...
  • ...therefore winmanager buffer stays unused
  • MiniBufExpl doesn't update itself properly when jumping between buffers

The behavior I have achieved is far from perfect but it's a good start.