2

Let's say I have some file

a
asdf
b
asdf
c

and search :vimgrep /asdf/g %, and open the quickfix list :copen. Now I can navigate between the two results using j/k and jump to said result using Enter. I find it inconvenient that we directly switch from the quickfix window to the window with the result. So far I just mapped :cprev and :cnext to some keys, but I'm wondering:

Is there some other short cut that acts like hitting Enter, but without switching to the result (i.e. staying in the quickfix list)?

3
  • You can easily map <CR> to behave differently in qflist (e.g., if in qflist, map to <CR>:cw<CR>). But I think your mapping of :cprev and :cnext is much more useful and hasslefree. Normally, specially in :grep as opposed to :make, user should not even care about the qflist. Just cycle through the results with proper and ample context. (In :make, one needs to read the error message, so that's a different matter.)
    – 3N4N
    Oct 18, 2022 at 10:27
  • @kadekai Thank you for the advice, that is a very good point! I think I'll stick with that then!
    – flawr
    Oct 18, 2022 at 12:54
  • 1
    @kadekai unless one wants to inspect the results/filter further/etc., in which case viewing the list is very handy.
    – D. Ben Knoble
    Oct 18, 2022 at 20:55

1 Answer 1

2

You can make your own mapping that opens the quickfix entry and comes back. Taken from vim-qf:

" in after/ftplugin/qf.vim
nnoremap <silent> <buffer> o <CR><C-w>p

See :help CTRL-W_p.

Your Answer

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

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