25

Eclipse is a great editor, and among it's many wonderful features one of my favorites is the Mark Occurrences feature. However, I recently installed the Aptana plug-in, and in trying to configure it I somehow managed to break Mark Occurrences in my Eclipse installation.

The feature still works somewhat, but instead of highlighting all occurrences of a given object, it now only highlights the occurrence where it is first created. In other words, in:

1. Dog dog = new Dog();
2. dog.bark();
3. dog.bark();

Only the "dog" in line 1 would be highlighted, not the "dog" in 2 or 3.

However, before I know I had things configured such that all three "dog" references would be highlighted by Eclipse. Does anyone know what configuration option I changed to "break" the marking of occurrences like this?

machineghost
  • 33,529
  • 30
  • 159
  • 234

7 Answers7

82

If the option mentioned by laurie is checked and you're wondering why it isn't working, you might have hit Alt-Shift-O sometime:

Cannot highlight all occurrences of a selected word in Eclipse

Note, that "Organize Imports" has Ctrl-Shift-O...

Community
  • 1
  • 1
Kawu
  • 13,647
  • 34
  • 123
  • 195
  • 1
    It's looks somehow a quite unprecise feature this Mark Occurences stuff. Thx for the shortcut anyway : i never noticed it before :) – Julien Jun 16 '14 at 15:00
  • 2
    thank you! I guess it might be a good idea to disable/remap alt-shift-o to avoid accidentally turning off occurrences marking. – ryenus Dec 30 '14 at 01:34
  • Wow! I almost gave up on my Eclipse setup, as I didn't have this (my favorite and most needed) feature working for several days. I disn't know that it was enableable and must have accidentally turned it of :-D. Thanks! – Janos Aug 12 '19 at 09:17
29

Check the following preference setting:

Preferences > General > Editors > Text Editors > Annotations

In here compare the settings for Occurrences and Write Occurrences.

You probably don't have the Text as higlighted option checked

Lii
  • 11,553
  • 8
  • 64
  • 88
laurie
  • 6,011
  • 4
  • 29
  • 22
23

There is another way to toggle the Mark Occurrences feature (apart from Preferences -> Java -> Editor -> Mark Occurrences)

Simply click the "Toggle Mark Occurrences" button from the toolbar. This can be seen in the image below. If you don't see the item in your bar you can turn on by selecting Window > Perspective > Customize Perspective... > Editor Presentation > Toggle Mark Occurrences

You can use a keyboard shortcut to toggle it, also:

  • On Windows: Alt + Shift + O
  • On OS X: Option + Command + O

Hope that helps

enter image description here

wired00
  • 13,930
  • 7
  • 70
  • 73
7

Preference > Java > Editor > Mark Ocurrences > check: Mark Ocurrences of the selected element in the current file.

Chia
  • 79
  • 1
  • 2
  • My problem was with Occurrences in general (and my specific editor was actually the JS one, so the Java editor had nothing to do with my case), but hopefully your answer will be relevant to others who find this thread. – machineghost Nov 09 '12 at 00:03
6

and eclipse won't highlight occurences if your project contains errors check the Problems view to be sure you project is clean

Bernard
  • 69
  • 1
  • 1
  • 3
    This was the answer for me. This has been driving me crazy for a long time. I don't understand why the Eclipse text editor can't just highlight all occurrences of the word, regardless of build problems. Even simple text editors like Notepad++ can do that without having to compile the code in a file. – Nathan Beach Mar 05 '13 at 17:25
2

Go

Java> Editor > Mark Occurrences

Uncheck "Keep Marks when the section changes" then click Ok

Restart Eclipse.

This work for me.

mfe
  • 1,158
  • 10
  • 15
0

Double click on the class or the package in it disappears. Have no fear.

( I also activated this feature by mistake while pressing selecting a word)

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
sivi
  • 10,654
  • 2
  • 52
  • 51