Created
June 9, 2010 15:45
-
-
Save nelstrom/431677 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Delete all inactive buffers by running: | |
" :call CloseHiddenBuffers() | |
" or the | |
" :Only | |
command! -nargs=* Only call CloseHiddenBuffers() | |
function! CloseHiddenBuffers() | |
" 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's loaded and not visible | |
for b in range(1, bufnr('$')) | |
if bufloaded(b) && !has_key(visible, b) | |
exe 'bd ' . b | |
endif | |
endfor | |
endfun | |
" http://stackoverflow.com/questions/1534835/how-do-i-close-all-buffers-that-arent-shown-in-a-window-in-vim |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment