Created
April 28, 2023 09:06
-
-
Save TummanapallyAnuraag/72a3b09e19bff61710e2b85521180726 to your computer and use it in GitHub Desktop.
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
" SOURCE: https://www.reddit.com/r/neovim/comments/mlqyca/fzf_buffer_delete/ | |
" HELP: Place this in ~/.vimrc or ~/.config/nvim/init.vim | |
" -------------------------------------------------------------------------- | |
" Add this for mapping Ctrl+x to trigger the action | |
" Delete buffers with fzf (refer ~/.config/nvim/custom.commands.vim) | |
nmap <C-x> :BD<CR> | |
" Everything below is copied from SOURCE mentioned above | |
" -------------------------------------------------------------------------- | |
"FZF Buffer Delete | |
function! s:list_buffers() | |
redir => list | |
silent ls | |
redir END | |
return split(list, "\n") | |
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(), | |
\ 'sink*': { lines -> s:delete_buffers(lines) }, | |
\ 'options': '--multi --reverse --bind ctrl-a:select-all+accept' | |
\ })) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment