Right now, I have my Emacs frame vertically split, and am looking at two different buffers in the two windows.
I'd like to go to a word in one buffer, hit some keys, and have the ocurrences of that word (if any) highlighted in the other buffer, scrolling to it if necessary.
Is there a way to do that?
In the screenshot above, with my cursor just before "bar" in the left buffer, I'd like to be able to <do something> and quickly see where "bar" is in the right buffer.
Note: This is related to How do I find text across multiple open buffers? in the sense that, if I could do an isearch across the "other" buffer, it would do what I want. But none of the answers there are exactly what I want:
- The
occur
based solutions open a new window that shows matching lines, while I'd like to keep my two windows still displayed -- I'm actually going to be looking in the other buffer for context around the match, so showing only the matching line is not very helpful. multi-isearch-buffers
requires me to specify the list of buffers every time I want to do this search (a lot of times), instead of automatically picking it up as the two displayed buffers. More importantly, when I start from one window and perform the isearch, when it finds the match in the other buffer it displays that buffer in this window, so that both windows display the same (other) buffer. Then C-g puts everything back, and I can't see the word highlighted in the other buffer any more.icicle-search
has so many features that one of them may be able to do this, but I wasn't able to find anything after a cursory look at the documentation.
C-s C-w C-x o C-s C-s
doesn't sound so bad to me. (You don't need aC-s
right after theC-w
.)C-s C-w C-x o C-s C-s C-x o
indeed seems fine.