Skip to content

Instantly share code, notes, and snippets.

@torgeir
Forked from skanev/close_hidden_buffers.vim
Last active October 7, 2017 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save torgeir/8964540 to your computer and use it in GitHub Desktop.
Save torgeir/8964540 to your computer and use it in GitHub Desktop.
close_hidden_buffers.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