blob: 731b3f020beb8fe2794a0e86632c80e1727c0522 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
|