Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@rongyi rongyi commented Nov 14, 2013

thanks!

@j5shi

This comment has been minimized.

Copy link

@j5shi j5shi commented Mar 22, 2016

Nice function!

@jeromedalbert

This comment has been minimized.

Copy link

@jeromedalbert jeromedalbert commented May 1, 2016

👍

@nguyentp

This comment has been minimized.

Copy link

@nguyentp nguyentp commented Sep 29, 2018

This solves my problem. Thanks!

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