6

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.

Drew
  • 77,472
  • 10
  • 114
  • 243
Stefano
  • 91
  • 3

1 Answers1

8

By default C-o 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.

phils
  • 50,977
  • 3
  • 79
  • 122
  • 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 09 '17 at 09:43
  • 2
    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 09 '17 at 09:55