Emacs question: display regexp search matches on scroll bar?

Viewed 30

Emacs question: Is there a way to display marks on the scrollbar where search matches are to be found in the buffer? Like hitting crtl-f in the new chrome? Best would be if multiple different searches could be displayed in different colours and different vertical bars?

1 Answers

I don't know how to display the matches on the scrollbar (I doubt it can be done in emacs-lisp).

But, as an alternative, you could use M-x occur RET <regexp> RET.

Emacs will open a buffer named *occur* containing the lines of the original buffer which match the regexp. Each line is preceded by its number in the original buffer and the strings which match the given regexp are highlighted. As emacs documentation says:

That buffer can serve as a menu for finding any of the matches
for REGEXP in the current buffer.

If you click or press RET on one of these lines, emacs will move the point to one of the items in the corresponding line in the original buffer.

You may then rename the buffer before calling again occur, in order to keep the two occur buffers active.

(and if you are smart enough, you may consider writing a function to mix the contents of the different occur buffers...)

Related