"============================================================================= " Copyright: Copyright (C) 2002 & 2003 Bindu Wavell " Permission is hereby granted to use and distribute this code, " with or without modifications, provided that this copyright " notice is copied with it. Like anything else that's free, " minibufexplorer.vim is provided *as is* and comes with no " warranty of any kind, either expressed or implied. In no " event will the copyright holder be liable for any damamges " resulting from the use of this software. " " Name Of File: minibufexpl.vim " Description: Mini Buffer Explorer Vim Plugin " Maintainer: Bindu Wavell " URL: http://vim.sourceforge.net/scripts/script.php?script_id=159 " Last Change: Monday, April 14, 2003 " Version: 6.2.5 " Derived from Jeff Lanzarotta's bufexplorer.vim version 6.0.7 " Jeff can be reached at (jefflanzarotta@yahoo.com) and the " original plugin can be found at: " http://lanzarotta.tripod.com/vim/plugin/6/bufexplorer.vim.zip " " Usage: Normally, this file should reside in the plugins " directory and be automatically sourced. If not, you must " manually source this file using ':source minibufexplorer.vim'. " " You may use the default keymappings of " " mbe - Opens MiniBufExplorer " " or you may want to add something like the following " key mapping to your _vimrc/.vimrc file. " " map b :MiniBufExplorer " " However, in most cases you won't need any key-bindings at all. " " is usually backslash so type "\mbe" (quickly) to open " the -MiniBufExplorer- window. " " Other keymappings include: mbc to close the Explorer " window, mbu to force the Explorer to Update and " mbt to toggle the Explorer window; it will open if " closed or close if open. Each of these key bindings can be " overridden (see the notes on mbe above.) " " You can map these additional commands as follows: " " map c :CMiniBufExplorer " map u :UMiniBufExplorer " map t :TMiniBufExplorer " " NOTE: you can change the key binding used in these mappings " so that they fit with your configuration of vim. " " You can also call each of these features by typing the " following in command mode: " " :MiniBufExplorer " Open and/or goto Explorer " :CMiniBufExplorer " Close the Explorer if it's open " :UMiniBufExplorer " Update Explorer without navigating " :TMiniBufExplorer " Toggle the Explorer window open and " closed. " " To control where the new split window goes relative to the " current window, use the setting: " " let g:miniBufExplSplitBelow=0 " Put new window above " " current. " let g:miniBufExplSplitBelow=1 " Put new window below " " current. " " The default for this is read from the &splitbelow VIM option. " " By default we are now (as of 6.0.2) forcing the -MiniBufExplorer- " window to open up at the edge of the screen. You can turn this " off by setting the following variable in your .vimrc: " " let g:miniBufExplSplitToEdge = 0 " " It is now (as of 6.1.1) possible to set a maximum height for " the -MiniBufExplorer- window. You can set the max height by " letting the following variable in your .vimrc: " " let g:miniBufExplMaxHeight = " " setting this to 0 will mean the window gets as big as " needed to fit all your buffers. " " As of 6.2.2 it is possible to set a minimum height for the " -MiniBufExplorer- window. You can set the min height by " letting the following variable in your .vimrc: " " let g:miniBufExplMinHeight = " " By default we are now (as of 6.0.1) turning on the MoreThanOne " option. This stops the -MiniBufExplorer- from opening " automatically until more than one eligible buffer is available. " You can turn this feature off by setting the following variable " in your .vimrc: " " let g:miniBufExplorerMoreThanOne=1 " " (The following enhancement is as of 6.2.2) " Setting this to 0 will cause the MBE window to be loaded even " if no buffers are available. Setting it to 1 causes the MBE " window to be loaded as soon as an eligible buffer is read. You " can also set it to larger numbers. So if you set it to 4 for " example the MBE window wouldn't auto-open until 4 eligibles " buffers had been loaded. This is nice for folks that don't " want an MBE window unless they are editing more than two or " three buffers. " " To enable the optional mapping of Control + Vim Direction Keys " [hjkl] to window movement commands, you can put the following into " your .vimrc: " " let g:miniBufExplMapWindowNavVim = 1 " " To enable the optional mapping of Control + Arrow Keys to window " movement commands, you can put the following into your .vimrc: " " let g:miniBufExplMapWindowNavArrows = 1 " " To enable the optional mapping of and to a " function that will bring up the next or previous buffer in the " current window, you can put the following into your .vimrc: " " let g:miniBufExplMapCTabSwitchBufs = 1 " " To enable the optional mapping of and to mappings " that will move to the next and previous (respectively) window, you " can put the following into your .vimrc: " " let g:miniBufExplMapCTabSwitchWindows = 1 " " " NOTE: If you set the ...TabSwitchBufs AND ...TabSwitchWindows, " ...TabSwitchBufs will be enabled and ...TabSwitchWindows " will not. " " MBE has had a basic debugging capability for quite some time. " However, it has not been very friendly in the past. As of 6.0.8, " you can put one of each of the following into your .vimrc: " " let g:miniBufExplorerDebugLevel = 0 " MBE serious errors output " let g:miniBufExplorerDebugLevel = 4 " MBE all errors output " let g:miniBufExplorerDebugLevel = 10 " MBE reports everything " " You can also set a DebugMode to cause output to be target as " follows (default is mode 3): " " let g:miniBufExplorerDebugMode = 0 " Errors will show up in " " a vim window " let g:miniBufExplorerDebugMode = 1 " Uses VIM's echo function " " to display on the screen " let g:miniBufExplorerDebugMode = 2 " Writes to a file " " MiniBufExplorer.DBG " let g:miniBufExplorerDebugMode = 3 " Store output in global: " " g:miniBufExplorerDebugOutput " " Or if you are able to start VIM, you might just perform these " at a command prompt right before you do the operation that is " failing. " " Known Issues: When debugging is turned on and set to output to a window, there " are some cases where the window is opened more than once, there " are other cases where an old debug window can be lost. " " Several MBE commands can break the window history so p " might not take you to the expected window. " " History: 6.2.5 o Added mbt key mapping which will toggle " the MBE window. I map this to F3 in my .vimrc " with "map :TMiniBufExplorer" which " means I can easily close the MBE window when I'm " not using it and get it back when I want it. " o Changed default debug mode to 3 (write to global " g:miniBufExplorerDebugOutput) " o Made a pass through the documentation to clarify " serveral issues and provide more complete docs " for mappings and commands. " 6.2.4 o Because of the autocommand switch (see 6.2.0) it " was possible to remove the restriction on the " :set hidden option. It is now possible to use " this option with MBE. " 6.2.3 o Added miniBufExplTabWrap option. It is turned " off by default. When turned on spaces are added " between tabs and gq} is issued to perform line " formatting. This won't work very well if filenames " contain spaces. It would be pretty easy to write " my own formatter, but I'm too lazy, so if someone " really needs that feature I'll add it :) " 6.2.2 o 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. " o 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. " o 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? :) " o Fixed a bug where an empty MBE window was taking half " of the screen (partly why the MinHeight option was " added.) " 6.2.1 o If MBE is the only window (because of :bd for example) " and there are still eligible buffers then one of them " will be displayed. " o The mbe mapping now highlights the buffer from " the current window. " o 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. " o Added a new key binding ('p') in the MBE window to " switch to the previous window (last edit window) " 6.2.0 o 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. " o Added g:miniBufExplMaxHeight variable so you can keep " the -MiniBufExplorer- window small when you have lots " of buffers (or buffers with long names :) " o 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 :) " o Added debug mode 3 which writes to a global variable " this is fast and doesn't mess with the buffer/window " lists. " 6.1.0 o mbc was failing because I was calling one of " my own functions with the wrong number of args. :( " Thanks to Gerry Patterson for finding this! " This code is very stable (although it has some " idiocyncracies.) " 6.0.9 o Double clicking tabs was overwriting the cliboard " register on MS Windows. Thanks to Shoeb Bhinderwala " for reporting this issue. " 6.0.8 o Apparently some VIM builds are having a hard time with " line continuation in scripts so the few that were here " have been removed. " o Generalized FindExplorer and FindCreateExplorer so " that they can be used for the debug window. Renaming " to FindWindow and FindCreateWindow. " o 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. " o 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 this " option set. " 6.0.7 o Handling BufDelete autocmd so that the UI updates " properly when using :bd (rather than going through " the MBE UI.) " o The AutoUpdate code will now close the MBE window when " there is a single eligible buffer available. " This has the usefull side effect of stopping the MBE " window from blocking the VIM session open when you close " the last buffer. " o Added functions, commands and maps to close & update " the MBE window (mbc and mbu.) " o Made MBE open/close state be sticky if set through " StartExplorer(1) or StopExplorer(1), which are " called from the standard mappings. So if you close " the mbe window with \mbc it won't be automatically " opened again unless you do a \mbe (or restart VIM). " o Removed spaces between "tabs" (even more mini :) " o Simplified MBE tab processing " 6.0.6 o Fixed register overwrite bug found by Sébastien Pierre " 6.0.5 o Fixed an issue with window sizing when we run out of " buffers. " o Fixed some weird commenting bugs. " o Added more optional fancy window/buffer navigation: " o You can turn on the capability to use control and the " arrow keys to move between windows. " o You can turn on the ability to use and " to open the next and previous (respectively) " buffer in the current window. " o You can turn on the ability to use and " to switch windows (forward and backwards " respectively.) " 6.0.4 o Added optional fancy window navigation: " o Holding down control and pressing a vim direction " [hjkl] will switch windows in the indicated direction. " 6.0.3 o Changed buffer name to -MiniBufExplorer- to resolve " Issue in filename pattern matching on Windows. " 6.0.2 o 2 Changes requested by Suresh Govindachar: " o Added SplitToEdge option and set it on by default " o Added tab and shift-tab mappings in [MBE] window " 6.0.1 o Added MoreThanOne option and set it on by default " MiniBufExplorer will not automatically open until " more than one eligible buffers are opened. This " reduces cluter when you are only working on a " single file. " NOTE: See change log for 6.2.2 for more details about " this feature " 6.0.0 o Initial Release on November 20, 2001 " " Todo: Provide better support for user defined syntax highlighting " This is improved as of 6.1.1 but it's still not perfect. " Todo: Add the ability to specify a regexp for eligible buffers " allowing the ability to filter out certain buffers that " you don't want to control from MBE " "============================================================================= " " Has this plugin already been loaded? " if exists('loaded_minibufexplorer') call DEBUG('MiniBufExplorer already loaded!', 5) finish endif let loaded_minibufexplorer = 1 let s:debugIndex = 0 " " If we don't already have a keyboard " mapping for mbe then create one. " if !hasmapto('MiniBufExplorer') map mbe MiniBufExplorer endif if !hasmapto('CMiniBufExplorer') map mbc CMiniBufExplorer endif if !hasmapto('UMiniBufExplorer') map mbu UMiniBufExplorer endif if !hasmapto('TMiniBufExplorer') map mbt TMiniBufExplorer endif " " Setup