Kill unseen/unused buffers

2 Points

Ferran Pelayo Monfort Ferran Pelayo Monfort

10 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