简体   繁体   中英

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

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截图

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.

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.

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.

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 (eg k in if(k > 1) ).
  2. The color of " Write Occurrences " is used where the variable gets modified/written to in the code (eg 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).

转到Windows / Preferences / Java / Editor / Mark Occurrences并选中“在当前文件中标记所选元素的出现次数”框。

更改“occurrence”的颜色后,重新启动Eclipse IDE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM