sponsor Vim development Vim logo Vim Book Ad

minibufexpl.vim : Elegant buffer explorer - takes very little screen space

 script karma  Rating 3716/1228, Downloaded by 101062    Comments, bugs, improvements  Vim wiki

created by
bindu wavell
 
script type
utility
 
description
Several modern GUI editors list your open buffers as tabs along the top or bottom of your screen (VisualStudio, DreamWeaver, EditPlus and UltraEdit come to mind), now we have this feature in VIM! You can checkout a screenshot here: http://www.wavell.net/vim/vim_screenshot.gif.

You can quickly switch buffers by double-clicking the appropriate "tab" (if you don't want to use the mouse just put the cursor on the "tab" and press enter). As you open and close buffers the tabs get updated. Buffers that are modified get visually marked and buffers that are open in a window get visually marked. The -MiniBufferExplorer- opens automatically when you open more than one eligible buffer (no need to open the explorer if you’re only editing one file.) -MiniBufExplorer- doesn't bother showing non-modifiable or hidden buffers. You can delete buffers by selecting them and pressing d on the keyboard.

When you are in the -MiniBufExplorer- window, Tab and Shift-Tab move forward and backward respectively through the buffer list.

There are a growing number of optional features in this script that are enabled by letting variables in your .vimrc:

  control + the vim direction keys [hjkl] can be made to move you between windows.
  control + arrow keys can be made to do the same thing
  control + tab & shift + control + tab can be setup to switch through your open windows (like in MS Windows)
  control + tab & shift + control + tab can alternatively be setup to cycle forwards and backwards through your modifiable buffers in the current window

NOTE: Some versions of vim don't support all of the key mappings that this script uses so you may experience degraded functionality. For example on Solaris SHIFT-TAB appears to fire the regular TAB mappings (same for console and gvim.) Also CONTROL+ARROWS appears to work in gvim on Solaris, but not in my xterm. All of the key bindings appear to work in Windows.

[Thanks to Jeff Lanzarotta for his BufExplorer plugin (http://vim.sourceforge.net/scripts/script.php?script_id=42) that got me started down this slippery slope.]

[While I still use vim to edit the odd file, I spend most of my time in one flavor or the other of eclipse (with the vim plugin of course.) As such this plugin has not seen any love from me in a very long time. Recently I've been contacted by several folks who have made significant progress on this script. As I'm not able to validate their work I'm currently not up for posting their changes. However, I'm very happy to provide a pointer to their work: Checkout https://github.com/fholgado/minibufexpl.vim ]

[Also, it appears that the TabBar plugin is a variant on MBE, you can read about what they have done here: http://www.vim.org/scripts/script.php?script_id=1338 ]
 
install details
Copy minibufexpl.vim into your plugin directory. Or :source minibufexpl.vim. That is all you need to get started.

If you want to enable extra functionality (documented in the source) you might want to add the following to your .vimrc:

  let g:miniBufExplMapWindowNavVim = 1
  let g:miniBufExplMapWindowNavArrows = 1
  let g:miniBufExplMapCTabSwitchBufs = 1
  let g:miniBufExplModSelTarget = 1

These are options that I expect most user will enjoy.

You can configure things like how tabs wrap, how big or small the explorer window is, if the explorer window is horizonal or vertical, the use of single or double click for buffer selection, what colors are used for the tabs in different states, how many buffers need to be open before the explorer window opens, etc. There are also some commands that you can use in your own key bindings for simple buffer manipulation. All of these options and more are documented at the top of the source file.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
minibufexpl.vim 6.3.2 2004-11-18 6.0 bindu wavell For some reason there was still a call to StopExplorer with 2 params. Many thanks to Jason Mills for reporting this!
minibufexpl.vim 6.3.1 2004-06-30 6.0 bindu wavell Added g:miniBufExplForceSyntaxEnable option for folks that are experiencing the vim bug where buffers show up without highlighting when another buffer has been closed, quit, wiped or deleted. This resolves all known issues with buffers loosing their highlighting. If you find a case that is not resolved, please report it :)

Folded source so that it's easier to navigate
minibufexpl.vim 6.3.0 2004-06-24 6.0 bindu wavell FEATURE RELEASE:
o Added optional single click to select buffers in the MBE window
o MBE is no longer included in :ls output
o Added the ability to have your tabs show up in a vertical window
o Autosize vertical explorer window

NOTE: Folks who use the single click feature in TagList should wait to use the MBE single click feature until the next release of TagList (~2 weeks) which includes a patch to allow both explorers to utilize single click.

CHANGE
o g:miniBufExplMaxHeight was renamed g:miniBufExplMaxSize
o g:miniBufExplMinHeight was renamed g:miniBufExplMinSize

The old settings are backwards compatible if you don't use the new settings. The old settings are depreciated.
minibufexpl.vim 6.2.8 2004-06-07 6.0 bindu wavell Added an option to stop MBE from targeting non-modifiable buffers when switching buffers. Those of you who use buffer explorers like taglist, project, etc and would like MBE to try not to place selected buffers into explorer windows will like this one :) To get this working download the latest version of minibufexpl.vim and put "let g:miniBufExplModSelTarget = 1" into your .vimrc. This is not a 100% guarantee, but it does a good job of trying to avoice explorer windows. Thanks to A.W. Law for the inspiration for this.
minibufexpl.vim 6.2.7 2004-05-24 6.0 bindu wavell Very minor bug fix for people who want to set loaded_minibufexplorer in their .vimrc in order to stop MBE from loading. 99.99% of users do not need this update. Thanks to bash for finding this.
minibufexpl.vim 6.2.6 2003-04-30 6.0 bindu wavell Very minor update: Moved history to end of source file. Updated highlighting documentation. Created global commands MBEbn and MBEbp that can be used in mappings if folks want to cycle buffers while skipping non-eligible buffers.
minibufexpl.vim 6.2.5 2003-04-13 6.0 bindu wavell Added a ToggleExplorer option and updated the documentation.
minibufexpl.vim 6.2.4 2003-03-30 6.0 bindu wavell MiniBufExplorer is now compatible with :set hidden.
minibufexpl.vim 6.2.3 2003-03-26 6.0 bindu wavell Added an optional feature to cause tabs to wrap. i.e. you should never get a tab name split across two lines (there is a potential issue if you have filenames with spaces, but otherwise this works.)
minibufexpl.vim 6.2.2 2003-03-25 6.0 bindu wavell Changed the way the g:miniBufExplorerMoreThanOne
global is handled. You can set this to the number
of eligible buffers you want to be loaded before
the MBE window is loaded. Setting it to 0 causes
the MBE window to be opened even if there are no
buffers. Setting it to 4 causes the window to stay
closed until the 4th eligible buffer is loaded.

Added a MinHeight option. This is nice if you want
the MBE window to always take the same amount of
space. For example set MaxHeight and MinHeight to 2
and set MoreThanOne to 0 and you will always have
a 2 row (plus the ruler :) MBE window.

I now setlocal foldcomun=0 and nonumber in the MBE
window. This is for those of you that like to have
these options turned on locally. I'm assuming noone
outthere wants foldcolumns and line numbers in the
MBE window? :)

Fixed a bug where an empty MBE window was taking half
of the screen (partly why the MinHeight option was
added.)
minibufexpl.vim 6.2.1 2003-03-21 6.0 bindu wavell If MBE is the only window (because of :bd for example) and there are still eligible buffers then one of them will be displayed.

The <Leader>mbe mapping now highlights the buffer from the current window.

The delete ('d') binding in the MBE window now restors the cursor position, which can help if you want to delete several buffers in a row that are not at the beginning of the buffer list.

Added a new key binding ('p') in the MBE window to switch to the previous window (last edit window)
minibufexpl.vim 6.2.0 2003-03-20 6.0 bindu wavell Major overhaul of autocommand and list updating code, we now have much better handling of :bd (which is the most requested feature.) As well as resolving other issues where the buffer list would not be updated automatically. The old version tried to trap specific events, this one just updates frequently, but it keeps track and only changes the screen if there has been a change.

Added g:miniBufExplMaxHeight variable so you can keep the -MiniBufExplorer- window small when you have lots of buffers (or buffers with long names :)

Improvement to internal syntax highlighting code I renamed the syntax group names. Anyone who has figured out how to use them already shouldn't have any trouble with the new Nameing :)

Added debug mode 3 which writes to a global variable this is fast and doesn't mess with the buffer/window lists.
minibufexpl.vim 6.1.0 2003-03-14 6.0 bindu wavell <Leader>mbc was failing because I was calling one of my own functions with the wrong number of args. Thanks to Gerry Patterson and others for finding this!
minibufexpl.vim 6.0.9 2002-09-17 6.0 bindu wavell Double clicking tabs was overwriting the clipboard register on MS Windows but not elsewhere... go figure :). This has now been fixed. Thanks to Shoeb Bhinderwala for reporting this one.
minibufexpl.vim 6.0.8 2002-08-06 6.0 bindu wavell Apparently some VIM builds are having a hard time with line continuation in scripts so the few that were here have been removed.


Updated debugging code so that debug output is put into a buffer which can then be written to disk or emailed to me when someone is having a major issue. Can also write directly to a file (VERY SLOWLY) on UNIX or Win32 (not 95 or 98 at the moment) or use VIM's echo function to display the output to the screen.

Several people have had issues when the hidden option is turned on. So I have put in several checks to make sure folks know this if they try to use MBE with the option set.
minibufexpl.vim 6.0.7 2002-02-04 6.0 bindu wavell Major update to how MBE handles buffer deletes. Now deletes are handled through an autocmd so you can now use :bd to delete buffers and the UI keeps in sync. Also made the MBE window go away when there is only one eligible buffer left to edit.
minibufexpl.vim 6.0.6 2002-01-28 6.0 bindu wavell Fixed register overwrite bug found by Sébastien Pierre. The @" register was being overwritten with the selected buffer name when switching buffers, the @" register is now preserved.
minibufexpl.vim 6.0.5 2002-01-22 6.0 bindu wavell Added more optional fancy window/buffer navigation:

You can turn on the ability to use control and the arrow keys to move between windows.
You can turn on the ability to use <C-TAB> and <C-S-TAB> to open the next and previous (respectively) buffer in the current window.
You can turn on the ability to use <C-TAB> and <C-S-TAB> to switch windows (forward and backwards respectively.)

Fixed an issue with window sizing when we run out of buffers.
minibufexpl.vim 6.0.4 2001-12-19 6.0 bindu wavell After reading 'Tip #173: Switch between splits very fast (for multi-file editing)' I decided to optionally add control+direction [hjkl] mappings to switch between windows. If you want to enable this feature just put 'let g:miniBufExplMapWindowNav=1" into your .vimrc.
minibufexpl.vim 6.0.3 2001-12-19 6.0 bindu wavell Our buffername [MiniBufExplorer] was being treated as a regular expression in some instances and matching several single character file names. Since escaping the '[' and ']' doesn't work on the windows version of vim 6.0 yet, I renamed the buffer -MiniBufExplorer-. This appears to have resolved the issue.
minibufexpl.vim 6.0.2 2001-12-04 6.0 bindu wavell 2 Changes requested by Suresh Govindachar
Added SplitToEdge option and set it on by default
Added tab and shift-tab mappings in [MBE] window
minibufexpl.vim 6.0.0 2001-12-01 6.0 bindu wavell Initial upload
ip used for rating: 54.83.167.152

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo