Kill unseen/unused buffers

1 Point

Ferran Pelayo Monfort Ferran Pelayo Monfort

5 years ago

For cleaning up the buffer list

function! BufferKill()
    let l:count = 0
    for b in range(1, bufnr('$'))
        if bufexists(b) && !bufloaded(b)
            execute 'bwipeout '.b
            let l:count += 1
        endif
    endfor
    echo 'Deleted ' . l:count . ' buffers'
endfunction