1

I use vimgrep with :cnew and :cold a lot. I could be looking at a vimgrep list from several vimgrep commands ago. Is there a way to refresh the vimgrep list without typing in the corresponding vimgrep command? It might be quite far up in the command history, so it often takes more time to find it. By refresh, I mean search through all the files that were searched in the original issuance of the vimgrep command. Some may have been changed due to editing.

1 Answer 1

1

You can always do <up> on the command line with a prefix of :vimgrep to make searching history easier. You may also want to check out q: and the use ?// to search for the command to re-execute.

Assuming the quickfix title is set correctly, you can use following the command:

:execute get(getqflist({'title':1}), 'title')

This however I am not certain this will work with all :grep/:make commands. You also need a newer Vim version to get the Quckfix list title (Vim 8+ I think).

If you find yourself doing this often you may want to bind a mapping or command.

command! -nargs=0 -bar QFRefresh execute get(getqflist({'title':1}), 'title')

For more help see:

:h getqflist()
:h :execute
:h :get
:h q:
:h cmdwin
:h c_Up
1
  • Thanks, Peter. I like your initial, simple suggestion best, since I'm up and running without a detour. I am also in a much-controlled environment, and upgrading anything would entail unimaginable amounts of time.
    – user36800
    Commented Apr 17, 2018 at 17:07

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.