Skip to content

Instantly share code, notes, and snippets.

@eduardoarandah
Created August 24, 2022 20:42
Show Gist options
  • Save eduardoarandah/487e29566bbdbda251e32fc69227b2a3 to your computer and use it in GitHub Desktop.
Save eduardoarandah/487e29566bbdbda251e32fc69227b2a3 to your computer and use it in GitHub Desktop.
Close all empty buffers with this function
function! CloseEmptyBuffers()
let buffers = filter(range(1, bufnr('$')), 'buflisted(v:val) && empty(bufname(v:val)) && bufwinnr(v:val)<0 && !getbufvar(v:val, "&mod")')
if !empty(buffers)
exe 'bw ' . join(buffers, ' ')
endif
endfunction
command! CloseEmptyBuffers :call CloseEmptyBuffers()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment