Java 如何更改 Eclipse 侧栏中突出显示的出现颜色?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2231191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 05:00:39  来源:igfitidea点击:

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

javaeclipsehighlighting

提问by matt b

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.

当您在 Eclipse 中启用“标记出现”时,将光标放在任何类型/变量/方法/等上将突出显示文本编辑器中的所有出现,并在右侧标尺中放置一个模糊的条以显示其他出现在文本编辑器中的位置文件。

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.

有谁知道您可以在首选项中的哪个位置更改用于突出显示侧标尺中其他事件的颜色?对于我当前的显示器/Windows Aero 主题,颜色对我来说太淡了。

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

日食截图

采纳答案by ColinD

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.

并更改 Occurrences 和 Write Occurrences 颜色。

回答by stacker

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

右键单击标记并选择唯一的菜单项“首选项”,这将打开首选项对话框: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.

使用“应用”按钮后,更新不会立即应用,只有在使用“确定”关闭并最终重新选择后才会应用。

回答by Pops

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

您需要更改“出现次数”和“写入出现次数”的颜色。这可以在 Annotations 菜单中完成,该菜单位于 - 正如 Colin 所说 - 在路径下的 Preferences 菜单中

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

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. kin if(k > 1)).
  2. The color of "Write Occurrences" is used where the variable gets modified/written to in the code (e.g. kin k = k + 1).
  1. Occurrences”的颜色用于在代码中读取变量但未修改的情况(例如kin if(k > 1))。
  2. Write Occurrences”的颜色用于在代码中修改/写入变量的地方(例如k在 中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).

另请参阅官方 Eclipse 文档,大约在页面的一半下方,在“定位变量及其读/写访问”和“标记事件”部分下(链接适用于 Eclipse“Indigo”版本,但应该适用于其他最新版本,如好)。

回答by amit

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

转到 Windows/Preferences/Java/Editor/Mark Occurrences 并选中“Mark Occurrences of the selected element in the current file”框。

回答by 2manyprojects

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.

并更改 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.

在 Eclipse Juno 中需要注意的一个区别(大多数其他响应似乎是指 Indigo)是更改在您重新启动程序之前不会生效。

回答by Sapto Sutardi

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

更改“出现次数”的颜色后,重新启动 Eclipse IDE