Skip to content

Instantly share code, notes, and snippets.

@skanev
Created July 6, 2011 20:15
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save skanev/1068214 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
@rongyi
Copy link

rongyi commented Nov 14, 2013

thanks!

@j5shi
Copy link

j5shi commented Mar 22, 2016

Nice function!

@jeromedalbert
Copy link

👍

@nguyentp
Copy link

This solves my problem. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment