Skip to content

Instantly share code, notes, and snippets.

@yriveiro
Forked from skanev/close_hidden_buffers.vim
Created August 3, 2016 09:34
Show Gist options
  • Save yriveiro/010420330d65c85232bb941efa1de7ed to your computer and use it in GitHub Desktop.
Save yriveiro/010420330d65c85232bb941efa1de7ed to your computer and use it in GitHub Desktop.
Close all hidden buffers in Vim
command! CloseHiddenBuffers call s:CloseHiddenBuffers()
function! s:CloseHiddenBuffers()
let open_buffers = []
for i in range(tabpagenr('$'))
call extend(open_buffers, tabpagebuflist(i + 1))
endfor
for num in range(1, bufnr("$") + 1)
if buflisted(num) && index(open_buffers, num) == -1
exec "bdelete ".num
endif
endfor
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment