I usually find myself running pattern replacements on the results of vim-fugitive's Ggrep

:Ggrep someFunctionName
:cfdo %s/someFunctionName/someOtherName/g | update

And that works great but I can still see someFunctionName on the quickfix matches.

I know the quickfix gets those values from another function and it doesn't keep track of the actual files, but I'm wondering if there's a way to read the locations and refresh them with the new content.

1 Answer 1


I am sure there is a better way, but this is how I would do it:

call setqflist(map(getqflist(), 'extend(v:val, {"text":get(getbufline(v:val.bufnr, v:val.lnum),0)})'))

Basically use getqflist() to get each Quickfix line. Using getbufline() to get each newly updated line. Then update the quickfix list via setqflist().

Note: This relies on getbufline() which requires the buffer to be loaded to get a line back properly (:cfdo should load the buffers).

For more help see:

:h setqflist()
:h getqflist()
:h map()
:h extend()
:h getbufline()
:h get()
:h :call
  • That's awesome stuff, thank you. I don't even need to worry about opening the buffers, cfdo already does that for me. I'll use your answer in this custom command: command! UpdateQF call setqflist(map(getqflist(), 'extend(v:val, {"text":get(getbufline(v:val.bufnr, v:val.lnum),0)})')) That way I can do: :cfdo %s//something/g | update | UpdateQF
    – davidmh
    Sep 21, 2017 at 20:16
  • 1
    Using UpdateQF inside cfdo %s//something/g | update | UpdateQF is creating a new quickfix list for every file. I imagine this could make quickfix list history useless. May want to do it as a separate command after the executing your :cfdo command. Sep 21, 2017 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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