aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2023-04-09 08:08:09 -0300
committerSilvio Rhatto <rhatto@riseup.net>2023-04-09 08:08:09 -0300
commit03ecd19878999cec293319963b5724379ca9cf98 (patch)
tree9c55d2d22a9623966149210390fc53ce9317d93a
parentfe7dd85e67144a1f01013ca1dfff538af42dd9d6 (diff)
downloadvim-03ecd19878999cec293319963b5724379ca9cf98.tar.gz
vim-03ecd19878999cec293319963b5724379ca9cf98.tar.bz2
Feat: adds the wipeout plugin
-rw-r--r--vim.dot.link/plugin/wipeout.vim32
1 files changed, 32 insertions, 0 deletions
diff --git a/vim.dot.link/plugin/wipeout.vim b/vim.dot.link/plugin/wipeout.vim
new file mode 100644
index 0000000..731b3f0
--- /dev/null
+++ b/vim.dot.link/plugin/wipeout.vim
@@ -0,0 +1,32 @@
+" wipeout.vim - Destroy all buffers that are not open in any tabs or windows.
+" https://www.vim.org/scripts/script.php?script_id=4882
+"
+" Adapted from the following StackOverflow answer:
+" http://stackoverflow.com/questions/1534835
+"
+" Author: Artem Nezvigin <artem@artnez.com>
+
+command! -bang Wipeout :call Wipeout(<bang>0)
+
+function! Wipeout(bang)
+ " figure out which buffers are visible in any tab
+ let visible = {}
+ for t in range(1, tabpagenr('$'))
+ for b in tabpagebuflist(t)
+ let visible[b] = 1
+ endfor
+ endfor
+ " close any buffer that are loaded and not visible
+ let l:tally = 0
+ let l:cmd = 'bw'
+ if a:bang
+ let l:cmd .= '!'
+ endif
+ for b in range(1, bufnr('$'))
+ if buflisted(b) && !has_key(visible, b)
+ let l:tally += 1
+ exe l:cmd . ' ' . b
+ endif
+ endfor
+ echon "Deleted " . l:tally . " buffers"
+endfun