如何修复 Eclipse 中的“标记事件”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1209423/
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-09-10 18:51:53  来源:igfitidea点击:

How to Fix "Mark Occurrences" in Eclipse?

eclipse

提问by machineghost

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.

Eclipse 是一款出色的编辑器,在它的众多出色功能中,我最喜欢的功能之一是 Mark Occurrences 功能。但是,我最近安装了 Aptana 插件,在尝试配置它时,我以某种方式设法打破了 Eclipse 安装中的 Mark Occurrences。

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.

只会突出显示第 1 行中的“狗”,而不是第 2 行或第 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?

但是,在我知道我已经配置好所有三个“狗”引用之前,Eclipse 都会突出显示。有谁知道我更改了什么配置选项以“破坏”这样的事件标记?

回答by Kawu

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

如果 laurie 提到的选项被选中并且你想知道它为什么不起作用,你可能会点击Alt- Shift-O某个时候:

Cannot highlight all occurrences of a selected word in Eclipse

无法在 Eclipse 中突出显示所有出现的选定单词

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

请注意,“组织导入”具有Ctrl- Shift- O...

回答by laurie

Check the following preference setting:

检查以下首选项设置:

Preferences > General > Editors > Text Editors > Annotations

首选项 > 常规 > 编辑器 > 文本编辑器 > 注释

In here compare the settings for Occurrencesand Write Occurrences.

在这里比较OccurrencesWrite Occurrences的设置。

You probably don't have the Text as higlightedoption checked

您可能没有选中Text as highlighted选项

回答by wired00

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

还有另一种方法可以切换标记出现次数功能(除了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

只需单击工具栏中的“切换标记出现”按钮。这可以在下图中看到。如果您在栏中没有看到该项目,您可以通过选择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
  • 在Windows上:Alt+ Shift+O
  • 在 OS X 上:Option+ Command+O

Hope that helps

希望有帮助

enter image description here

在此处输入图片说明

回答by Chia

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

Preference > Java > Editor > Mark Ocurrences > check:标记当前文件中所选元素的出现次数。

回答by Bernard

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

如果您的项目包含错误检查问题视图以确保您的项目是干净的

回答by mfe

Go

Java> Editor > Mark Occurrences

Java> 编辑器 > 标记出现次数

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

取消选中“部分更改时保留标记”,然后单击“确定”

Restart Eclipse.

重新启动 Eclipse。

This work for me.

这对我有用。

回答by sivi

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)

(我在按选择单词时也错误地激活了此功能)