sponsor Vim development Vim logo Vim Book Ad

bufkill.vim : Unload/delete/wipe a buffer, keep its window(s), display last accessed buffer(s)

 script karma  Rating 275/98, Downloaded by 4240    Comments, bugs, improvements  Vim wiki

created by
John Orr
 
script type
utility
 
description
Basic Usage:
When you want to unload/delete/wipe a buffer, use:
  :bun/:bd/:bw to close the window as well (vim command), or
  :BUN/:BD/:BW to leave the window(s) intact (this script).
To move backwards and forwards through the chronological
list of buffers accessed, use :BB and :BF, respectively.
Mappings are also defined.

Detailed Description:
This is a script to
a) unload, delete or wipe a buffer without closing the window (or windows)
    it was displayed in
b) in its place, display the buffer most recently used in each window
    it was displayed in.  This selection is taken from the full list of
    buffers ever displayed in each respective window (since vim was started)
c) allow one level of undo in case you kill a buffer then change your mind
d) allow various customizations via option variables

Since the script maintains a list of buffer access order for each window,
commands are also provided to move backwards and forwards between
the buffers in this order, similar to going backwards and forwards in a
web browser.

The inspiration for this script came from
a) my own frustration with vim's lack of this functionality
b) the description of the emacs kill-buffer command in vimtip #622
   (this script basically duplicates this command I believe,
   not sure about the undo functionality)
c) comments and many mails from Keith Roberts when the issue was
   raised in the vim@vim.org mailing list.
 
install details
The usual - drop the file into your $HOME/.vim/plugin directory (unix)
or $HOME/vimfiles/plugin directory (Windows), etc.
Use the commands/mappings defined to invoke the functionality
(or redefine them elsewhere to what you want), and set the
User Configurable Variables as desired.  You should be able to make
any customisations to the controls in your vimrc file, such that
updating to new versions of this script won't affect your settings.
 

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
bufkill.vim 1.11 2012-12-11 7.0 John Orr Major bug fixes by David Emett, especially relating to
the creation of new buffers when the last buffer is killed.
Also improved restoring of column on console vim.
Key mappings can be disabled by setting g:BufKillCreateMappings to 0
(thanks to various contributors)
bufkill.vim 1.10 2011-06-16 7.0 John Orr Improved handling of quickfix buffers, and various other fixes
bufkill.vim 1.9 2010-12-30 7.0 John Orr Remove unnecessary mapping delays, and a debug message
bufkill.vim 1.8 2010-12-30 7.0 John Orr Improved mapping handling, and robustness
bufkill.vim 1.7 2010-06-12 7.0 John Orr Convert to Vim 7 lists instead of string-based lists.
Add buffer navigation (move backwards and forwards through most recently used buffers), support for scratch buffer removal.
Improved honouring of the 'confirm' vim option - thanks Magnus Thor Torfason
Added (opt-in) Ctrl-^ override support to preserve cursor column.
Minor additional improvements.
bufkill.vim 1.2 2010-06-12 6.0 John Orr Add column-saving support, to ensure returning to a buffer means positioning the cursor not only at the right line, but also column.
Last version that will (should...) work with Vim 6.0.
bufkill.vim 1.1 2004-12-01 6.0 John Orr Fix handling of modified, un-named buffers
bufkill.vim 1.0 2004-12-01 6.0 John Orr Initial upload
ip used for rating: 54.91.120.148

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