vim-bufkill
vim-bufkill copied to clipboard
Smart bufkill option?
Could be cool if there was a single :SmartClose
command that we could map. This command might behave as follows...
- If there is an active buffer open in the window, perform a :BD (leaving window)
- If there is no buffer left in window, :bd (closing window)
- If it's the last window, and there is no buffer left in window, :q (quit vim altogether)
The last fallback option there might be a bit overzealous, but maybe could be handy? What are your thoughts?
Hi @jesseleite, my workaround is as follows, so that E516: No buffers were deleted
can be avoided. I don't like quiting vim accidentally, so I skip your last requested feature.
function! SmartBufKill()
let active_buffer_count=len(getbufinfo({'buflisted':1}))
if expand('%:p') != '' && active_buffer_count > 1
BD
else
bd
endif
endfunction
noremap <silent> <C-c> :call SmartBufKill()<cr>