created March 8, 2004 · complexity basic · author charles · version 5.7
GVim does not have a buffer bar (i.e. a toolbar with buffer names listed), but we can make a simple one by using (GUI only)
this will float (:help tearoff) the Buffers menu, giving an easier access to switching buffers. The advantage of using this floating menu is that we does not have to switch mode and giving commands everytime we want to switch buffer also it gives the list of files currently being edited.
The problem is that when you switch buffer, the floating menu disappear. To make it always appear, we can put this command in your vimrc:
autocmd VimEnter * tearoff Buffers
The floating menu will become quite lenghty if we open many buffers, to make it somehow smaller, we can edit the file menu.vim in $VIMRUNTIME to make it (1) show only the filename, not with the path and (2) not showing the delete, refresh, etc, since these command can easily done from command mode (:help buffer). For the first one, we can set this variable to 0
in our vimrc
and for the second one, we can use this command (assuming the commands are around lines 563-573, in my menu.vim -> may differ to yours)
the order of these commands does matter. You should check if the command are really located in those lines, the commands to be commented are
exe 'an <silent> ' . g:bmenu_priority . ".2 &Buffers.&Refresh\\ menu :call <SID>BMShow()<CR>" exe 'an ' . g:bmenu_priority . ".4 &Buffers.&Delete :bd<CR>" exe 'an ' . g:bmenu_priority . ".6 &Buffers.&Alternate :b #<CR>" exe 'an ' . g:bmenu_priority . ".7 &Buffers.&Next :bnext<CR>" exe 'an ' . g:bmenu_priority . ".8 &Buffers.&Previous :bprev<CR>" exe 'an ' . g:bmenu_priority . ".9 &Buffers.-SEP- :"
After that, restart gVim.
Comments[edit | edit source]
I'd like to use winanager and bufexplorer
map <F2> :WMToggle<CR>
it make it easy.
I use Winmanager and Bufexplorer too, but we stll have to switch to normal mode then select the buffer and then switch to insert mode again. I just think it'd be easier if we can switch buffer with just a mouse click away.
In gvim, I find it simpler to use "Alt+B" to open the buffer menu, then select the wanted buffer with the arrow keys.
How does one tell the torn off Buffers menu (or for that matter the title bar one) to not collapse until say, 50 items. Right now in 7.2 it appears to start collapsing at > 25 items which is annoying with resolutions today. I poked through menu.vim but did not see anything apparent. Hopefully it is exposed somehow?
Just checked menu.vim too and found that 'set menuitems=50' in your vimrc file should help