How to change highlighted occurrences color in Eclipse's sidebar?
Asked Answered
G

6

113

When you have "Mark occurrences" enabled in Eclipse, placing the cursor on any type/variable/method/etc will highlight all occurrences in the text editor and place a faint bar in the right ruler to show you the location of other occurrences in the file.

Does anyone know where in the Preferences you can change what color is used to highlight the other occurrences in the side ruler? The color is way too faint for me with my current monitor/Windows Aero theme.

I tried to go into Preferences > General > Appearance > Color and Fonts change the color for "Color labels - match highlight" but this didn't seem to apply.

Here is a screenshot with what I am talking about:

Eclipse screenshot

Ginnie answered 9/2, 2010 at 17:49 Comment(1)
Hmm, is it possible to change the color of the Side-Bar (Overview Bar) ? If it could be set to a darker shade of grey, the occurences would be visible with higher contrast.Wearing
C
190

The color in the bar is the same as the color the text is highlighted with in the editor. It is set by going to

Window > Preferences > General > Editors > Text Editors > Annotations

and changing the Occurrences and Write Occurrences colors.

Chrystalchryste answered 9/2, 2010 at 18:3 Comment(8)
thanks, I was looking at this window earlier and must have missed the Color icon.Ginnie
a little annoying that you can't have separate colors for text and the sidebar, but oh wellGinnie
Well, if they weren't the same, then it would be a lot less obvious what the color on the right corresponded to in the code. It probably didn't even occur to the eclipse guys to let them be different.Denominative
changing "Text as" -> Box, makes it bearable to use dark colorErund
i connect to remote machine and then use eclipse. the issue i am facing is it takes some 5-6 seconds to highlight the matching words. what might be the reason?Scalene
What's the difference between "Occurences" and "Write Occurrences"?Utopian
Nevermind, Pops answers that here: https://mcmap.net/q/193539/-how-to-change-highlighted-occurrences-color-in-eclipse-39-s-sidebar. Thanks, Pops!Utopian
This is so hard to find. I have to come here to find it every time or I am lost.Forfeit
B
11

Right click on the marker and select the only menu item "preferences", this opens the preferences dialog: General/Editors/text Editor/Annotation.

  • The color of "occurances" is used for the matching items,

  • "write occurances" for item selected by you.

The updates do not apply immediatly after using the Apply button, only after closing with OK and eventually reselect.

Baily answered 9/2, 2010 at 18:4 Comment(1)
"'write occurrences' for item selected by you". No, write occurrences are those occurrences that assign a value, as explained by @Pops.Unicef
S
7

The bar is called the Overview Bar or Overview Ruler (in case you need to reference it) and, as has been mentioned, the color of occurences can be changed by navigating to:

Window > Preferences > General > Editors > Text Editors > Annotations

and changing the color for Occurrences.

One difference to note in Eclipse Juno (most other responses seem to refer to Indigo) is that the change won't take effect until you restart the program.

Stablish answered 7/3, 2013 at 19:15 Comment(1)
same for Luna, i could not find the correct setting because nothing changed at first..Eisenberg
S
6

You'll want to change the "Occurrences" and "Write Occurrences" colors. This can be done in the Annotations menu, which is located — as Colin said — in the Preferences menu under the path

Window > Preferences > General > Editors > Text Editors > Annotations

If you have an occurrence marked in the overview ruler (the column to the right of the scrollbar), you can open the Annotations menu directly by right-clicking on the occurrence and selecting "Preferences" from the context menu.

Occurences have two color options:

  1. The color of "Occurrences" is used for instances where the variable is being read, but not modified, in the code (e.g. k in if(k > 1)).
  2. The color of "Write Occurrences" is used where the variable gets modified/written to in the code (e.g. k in k = k + 1).

See also the official Eclipse documentation, about halfway down the page, under the sections "Locate variables and their read/write access" and "Mark occurrences" (link is for Eclipse "Indigo" version, but should be good for other recent versions as well).

Semiramis answered 7/2, 2012 at 18:0 Comment(0)
T
3

Go to Windows/Preferences/Java/Editor/Mark Occurrences and check the box "Mark Occurrences of the selected element in the current file."

Tristan answered 6/9, 2012 at 10:57 Comment(1)
The question starts with "When you have "Mark occurrences" enabled in Eclipse", this post does not answer the question.Unicef
G
2

After changed the color of "occurances", restart your Eclipse IDE

Geotaxis answered 8/11, 2015 at 8:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.