fzf.vim
fzf.vim copied to clipboard
Add support to delete buffers in :Buffers command
By pressing the CTRL-D keybinding.
Also enabled the -m
multi select option to be able to delete multiple buffers.

Would it be possible to also include Ctrl-W for buffer-wipe and also the possibility to delete/wipe the current (%) buffer which is currently unfortunately unselectable ?
Hi @dav-dev! I tried to make this patch as small as possible to increase the probability of being merged (easier to review, no big changes, etc). Let's first hear what the maintainers have to say and then we can improve upon (if gets merged haha). WDYT?
@junegunn Lets get this merged.. This is super useful for power users
@mracos What do you think about "select all" buffers matching the search pattern for deletion ? I'm thinking add "Ctrl-a" to do select all and ctrl-d to delete them
Hey peeps 👋
Is this something that could be added in config via fzf_action
? or can :Buffers
not be customized in the same way as :Files
?
" Delete a buff
function! s:delete_buffer(args)
" Delete buffer here...
endfunction
let g:fzf_action = {
\ 'ctrl-q': function('s:build_quickfix_list'),
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit',
\ 'ctrl-d': function('s:delete_buffer'),
\ }
https://github.com/perrupa/dotfiles/blob/master/vim/plugin/fzf.vim#L13-L17
I found this PR trying to add something like above in my .vimrc and would love to help if possible. 👌
I was looking for this feature and found this PR. It's exactly what I'm missing, any potential to get it merged?
Sending my encouragement to get this exact functionality merged into fzf.vim. Would absolutely love it.
@mracos, I think it would be a really nice touch if CTRL+D
did not close the :Buffers
window, but instead closed the selected buffers and simply updated the :Buffers
window. Further, when I tried your branch mracos:mf-add-delete-option-to-buffers-command, :Buffers
no longer seem to honor my keybindings within the :Buffers
window.
@mracos, I think it would be a really nice touch if
CTRL+D
did not close the:Buffers
window, but instead closed the selected buffers and simply updated the:Buffers
window. Further, when I tried your branch mracos:mf-add-delete-option-to-buffers-command,:Buffers
no longer seem to honor my keybindings within the:Buffers
window.
I too think this is the ideal behavior. I have been thinking about this feature for a long time, and after reading the changes here and the source code a bit, I think it'll require rather large rewrites to function! s:fzf
and to function! fzf#run
(from junegunn/fzf).
The problem is that currently this PR uses the --expect ctrl-d
fzf argument, and not --bind=ctrl-d:execute(<cmd>)
. The hard part is to make <cmd>
delete the line from the query, which is currently held in a temporary file when you run :Buffers
.
The current implementation is great never the less, thanks for putting the hard work!
Hey folks, thank you so much for the investigation and interest. It's been a while since I've last touched this PR and I have stopped using fzf.vim
ever since 😞
So if anyone wants feel free to pick up this PR from there or even redo it from scratch, given that it's stale it might be easier
See PR above as a proposed solution. I have just a few comments on the thread:
@mracos What do you think about "select all" buffers matching the search pattern for deletion ? I'm thinking add "Ctrl-a" to do select all and ctrl-d to delete them
While it is possible and relatively easy to use fzf's --bind
to set ctrl-a:select-all
. I did not include this in the PR as this behavior is inconsistent across fzf.vim and in other areas alt-a:select-all
is used. I think it would be useful to have a consistent behavior for all functions that use --multi
.
Would it be possible to also include Ctrl-W for buffer-wipe and also the possibility to delete/wipe the current (%) buffer which is currently unfortunately unselectable ?
Adapting this PR to allow CTRL-W to execute :bwipeout
is trivial to implement, but as the vim :help :bwipeout
suggests you should only do this "if you know what you're doing". Usually :bdelete
is sufficient and should be the more common use case, so I didn't implement this. Deleting or wiping the current buffer is as simple as typing :bd
or :bw
and I did not feel this needed to be an additional functionality within the plugin.
BTW I use https://github.com/ibhagwan/fzf-lua which has this feature.