diff --git a/README b/README index 8954b3f..580cfb2 100644 --- a/README +++ b/README @@ -1,15 +1,19 @@ -This is a mirror of http://www.vim.org/scripts/script.php?script_id=2103 - -This is an improved version of kwbd.vim. It allows you to delete a buffer without closing the window. It meets the following criteria: +This is a mirror of [kwbd.vim](http://www.vim.org/scripts/script.php?script_id=2103) +Further improved by vim-scripts, fancypantalons (check for modified buffer), seb-mueller (bD mapping, docu) and jranke (typos) +https://github.com/vim-scripts/kwbdi.vim +https://github.com/fancypantalons/kwbdi.vim +https://github.com/fancypantalons/kwbdi.vim +https://github.com/seb-mueller/kwbdi.vim +It allows you to delete a buffer without closing the window. It meets the following criteria: * The window layout must be kept in all circumstances. - * If there is an alternate buffer must be showing that. - * If there is not alternate buffer then must be showing the preious buffer. - * If there is no alternate nor previous buffer (it is the only buffer) must show an empty buffer. + * If there is an alternate buffer, the window must show that instead. + * If there is no alternate buffer then the window must show the previous buffer. + * If there is no alternate nor previous buffer (it is the only buffer) it must show an empty buffer. If there are two windows with the same buffer open, both windows will remain open, and the buffer will be deleted -To delete a buffer while keeping the window open, just type \bd +To delete a buffer while keeping the window open, just type **bd** Thanks to the authors of kwbd.vim and minibufexpl.vim! diff --git a/doc/kwbdi.txt b/doc/kwbdi.txt new file mode 100644 index 0000000..5c90273 --- /dev/null +++ b/doc/kwbdi.txt @@ -0,0 +1,55 @@ +*kwbdi.txt* Delete a buffer while keeping the window open + +============================================================================== +Introduction *kwbdi* + +In order to unload and delete a buffer from the buffer list, :bd is your friend +(:h bd). An often unpleasant side effect is that this also closes the window +changing the window layout. + +Kwbdi allows you to delete a buffer without closing the window. It meets the +following criteria: + + * The window layout must be kept in all circumstances. + * If there is an alternate buffer, the window must show that instead. + * If there is no alternate buffer then the window must show the previous + buffer. + * If there is no alternate nor previous buffer (it is the only buffer) it + must show an empty buffer. + +If there are two windows with the same buffer open, both windows will remain +open, and the buffer will be deleted. + +============================================================================== +Usage *kwbdi-usage* + +bd Delete the current buffer while keeping the window open. + Throws an error and doesn't delete the buffer if it is modified + (safe option) + +bD Same as above but changes in the current buffer are discarded + without asking, simulating :bd! (be careful!). + +================================================================================ +Alternatives *kwbdi-alternatives* + +bufkill.vim (http://www.vim.org/scripts/script.php?script_id=1147) + +The mapping gives similar behaviour: + + :nmap bd :b#bd# + + :command Bd bp\|bd \# + +Credit for those solutions and contributors of this thread: +https://stackoverflow.com/questions/4298910/vim-close-buffer-but-not-split-window + +================================================================================ +Credits *kwbdi-credits* + +Thanks to the authors of kwbd.vim and minibufexpl.vim! + +Improvements by: +Ben Booth https://github.com/vim-scripts/kwbdi.vim +Brett Kosinski https://github.com/fancypantalons/kwbdi.vim +seb-mueller https://github.com/seb-mueller/kwbdi.vim diff --git a/doc/tags b/doc/tags new file mode 100644 index 0000000..899b7c8 --- /dev/null +++ b/doc/tags @@ -0,0 +1 @@ +kwbdi.txt kwbdi.txt /*kwbdi.txt* diff --git a/plugin/kwbdi.vim b/plugin/kwbdi.vim index 66058e4..a7b23bc 100644 --- a/plugin/kwbdi.vim +++ b/plugin/kwbdi.vim @@ -12,11 +12,27 @@ let loaded_kwbd = 1 if !hasmapto('Kwbd') map bd Kwbd + map bD KwbdForce endif -noremap