3

I was wondering if there is a way to visit the matches listed in the grep buffer without actually switching to the match buffer, similarly to C-o with Occur.

5

I'm awfully confused if you didn't actually try C-o, because by default that same binding does exactly what you want in grep buffers as well as in occur buffers.

You can also simply navigate up and down inside the grep results buffer with p and n (previous-error-no-select, next-error-no-select), and the other buffer will be updated each time.

Outside of the grep results buffer, M-gM-p and M-gM-n (previous-error, next-error) will visit the previous/next grep hit without you needing to select the grep buffer at all.

Note that these are all generic compilation-mode behaviours, which is why the command names use the term "error", as the functionality was originally written to make it easy to navigate the sources of compiler errors.

| improve this answer | |
  • Thanks Phils. C-o doesn't work the same way as in Occur for me, but n and p do, which is even better. M-g and M-p come very handy too. – Stefano Jan 9 '17 at 9:43
  • C-o should be bound to compilation-display-error in grep-mode buffers. If it isn't, something in your config must be clobbering it, so you should probably find out what that is and fix it. – phils Jan 9 '17 at 9:55

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.