Created
October 16, 2022 12:33
-
-
Save maguroguma/be13f4d16afab52bf3b26a4f10c4412b to your computer and use it in GitHub Desktop.
customized version of https://github.com/junegunn/fzf.vim/pull/733#issuecomment-559720813
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
" deletes buffers by fzf | |
" ref: https://github.com/junegunn/fzf.vim/pull/733#issuecomment-559720813 | |
function! s:list_buffers_customized() | |
redir => list | |
silent ls | |
redir END | |
let l:res = [] | |
let l:raw_lines = split(list, "\n") | |
for l:raw_line in raw_lines | |
let l:elems = split(l:raw_line) | |
let l:custom_line = l:elems[0] . "\t" . substitute(l:elems[2], '"', "", "g") | |
call add(l:res, l:custom_line) | |
endfor | |
return l:res | |
endfunction | |
function! s:delete_buffers(lines) | |
execute 'bwipeout' join(map(a:lines, {_, line -> split(line)[0]})) | |
endfunction | |
command! BD call fzf#run(fzf#wrap({ | |
\ 'source': s:list_buffers_customized(), | |
\ 'sink*': { lines -> s:delete_buffers(lines) }, | |
\ 'options': '--multi --reverse --bind ctrl-a:select-all+accept --prompt "delete(close) buffers> "' | |
\ })) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment