Created
August 24, 2022 20:42
-
-
Save eduardoarandah/487e29566bbdbda251e32fc69227b2a3 to your computer and use it in GitHub Desktop.
Close all empty buffers with this function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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