1

I'd like to search for a regex using Ag. This results in more than 1000 findings. I'd like to save these findings in a buffer to be able to go through them slowly

2
2

Check :h fzf-examples:

" An action can be a reference to a function that processes selected lines
function! s:build_quickfix_list(lines)
  call setqflist(map(copy(a:lines), '{ "filename": v:val }'))
  copen
  cc
endfunction

let g:fzf_action = {
  \ 'ctrl-q': function('s:build_quickfix_list'),
  \ 'ctrl-t': 'tab split',
  \ 'ctrl-x': 'split',
  \ 'ctrl-v': 'vsplit' }

let $FZF_DEFAULT_OPTS = '--bind ctrl-a:select-all'

Having this you can select all candidates with ctrl-a and press ctrl-q to put them into quickfix. And if needed copy/paste lines from there to a new buffer.

enter image description here

PS, I have actually tried to directly populate a new buffer but couldn't do it. Filled an issue to clarify this https://github.com/junegunn/fzf/issues/2164

PPS, found in source code that for grep-like fzf (grep, ag, rg) selected multiple lines are put into quickfix. So you don't need to provide ctrl-q to g:fzf_action just $FZF_DEFAULT_OPTS to select all candidates then select and press Enter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.