2

In notepad++, I could search a folder, and then click the match line to display the matched line of the corresponding buffer. How to do this in emacs?

What I can do now is to press "ENTER" on the matched line. But that moves the cursor to the other window with the matched data. But I don't want to move the cursor. Is this doable? Or anyway to click the matched line?

Kaushal Modi
  • 25,203
  • 3
  • 74
  • 179
Daniel Wu
  • 1,711
  • 2
  • 17
  • 26

1 Answers1

1

You can make the process of reviewing the grep matches smoother by using the emacs way of interacting with the *Compilation* family of buffers.

This solution does not specifically solve your question on how to show the matched line without moving the cursor but it helps you navigate the grep results as probably intended in emacs.

Here are the steps:

  1. Run grep using M-x grep. For the sake of example, let's say you are running grep in your ~/.emacs.d/ and you enter the grep arguments as require *.el.
  2. Now here are few default bindings and commands that will help you navigate the results in a convenient manner while the point is in the actual file buffer on the matched line:
    • M-x next-error to navigate to the next grep result. The default bindings are M-g M-n or C-x `.
    • M-x previous-error to navigate to the previous grep result. The default binding is M-g M-p.
    • M-x first-error to navigate to the first grep result.

Do not be confused by the term 'error' in the functions above. It is a generic term used in *Compilation* buffers.

Kaushal Modi
  • 25,203
  • 3
  • 74
  • 179