Eclipse 突出显示相同出现的单词

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

Eclipse highlighting the same occurrence of the word

eclipseeclipse-pluginsyntax-highlighting

提问by Ken Chan

In Notepad++ , it has a very nice feature that if I select a word , it will highlight all the same words throughout the text . Added to this , I can set the hot-keys to highlight up to five different words with different styles (See the effect below) .

在 Notepad++ 中,它有一个非常好的功能,如果我选择一个单词,它将突出显示整个文本中的所有相同单词。除此之外,我可以设置热键以突出显示最多五个不同样式的不同单词(请参阅下面的效果)。

enter image description here

在此处输入图片说明

Is there any ways /plug-ins to get this similar effect in eclipse ? I know when editing Java , it will highlight all the same variables ,but it will not work when I highlight the comments and editing other files type (e.g. xml, html, js, css and etc).

有没有什么方法/插件可以在 eclipse 中获得这种类似的效果?我知道在编辑 Java 时,它会突出显示所有相同的变量,但是当我突出显示注释和编辑其他文件类型(例如 xml、html、js、css 等)时,它将不起作用。

回答by fgysin reinstate Monica

I've been working with Eclipse for quite a while and I'm pretty certain that there is no canonical way of doing this.

我使用 Eclipse 已经有一段时间了,我很确定没有规范的方法可以做到这一点。

In Eclipse these things are managed on a per-editor basis and the Java editor does not support what your looking for for all I know. At least for the Java editor you can do some minor configuration in what is highlighted and how (Preferences > Java > Editor > Mark Occurrences), but I guess you already know that.

在 Eclipse 中,这些东西是在每个编辑器的基础上管理的,Java 编辑器不支持您所寻找的所有我知道的东西。至少对于 Java 编辑器,您可以对突出显示的内容和方式 ( Preferences > Java > Editor > Mark Occurrences)进行一些小的配置,但我想您已经知道了。

As for plugins, I'm not aware of any plugin that achieves what you're looking for. As a matter of fact I'd be surprised if there really was a plugin which achieves what you're looking for.

至于插件,我不知道有任何插件可以实现您的需求。事实上,如果真的有一个插件可以实现你正在寻找的东西,我会感到惊讶。

If something comes up I'd much appreciate you sharing it here, I've been trying to get decent highlighting into Eclipse for years unsuccessfully... :)

如果出现什么问题,我非常感谢您在这里分享它,多年来我一直试图在 Eclipse 中进行体面的突出显示,但没有成功...... :)

回答by winxton

Here is a plugin for eclipse: http://ystrot.github.io/glance/

这是 Eclipse 的插件:http: //ystrot.github.io/glance/

It highlights all occurrences as with notepad++ upon hitting Ctrl + Alt + F.

在按 Ctrl + Alt + F 时,它会像记事本 ++ 一样突出显示所有出现的事件。

回答by Sumit Singh

If you enable "Mark Occurrences" , then all words that are the same as the one you have marked will be highlighted.

如果您启用“标记出现次数”,则所有与您标记的单词相同的单词都将突出显示。

You can enable it in two following ways

您可以通过以下两种方式启用它

  1. Alt + Shift + O
  2. Preferences > Java > Editor > Mark Occurrences

    enter image description here

  1. Alt + Shift + O
  2. Preferences > Java > Editor > Mark Occurrences

    在此处输入图片说明

回答by Daniel Sokolowski

Below is what I found works for me but you can also assign a key shortcut to 'Find Text in File':

以下是我发现对我有用的内容,但您也可以为“在文件中查找文本”分配一个快捷键:

  1. Select the word or section of text
  2. Press CTR+3to activate 'Quick Access' search
  3. Type 'Find Text in File'
  4. Execute
  1. 选择单词或文本部分
  2. 按下CTR+3以激活“快速访问”搜索
  3. 输入“在文件中查找文本”
  4. 执行

As mentioned by @Kislingk you can modify how the words are highlighted/marked in 'Preferences > General >Editors>Text Editors > Annotations'.

正如@Kislingk 所提到的,您可以修改“首选项> 常规>编辑器>文本编辑器> 注释”中突出显示/标记单词的方式。

eclipse-highlight-search-results-in-file

eclipse-highlight-search-results-in-file

回答by Roo

Here is the closest solution I have found:

这是我找到的最接近的解决方案:

  1. Create a shortcut in Preferences/General/Keys type in the search field: "Find Text in File" By default it has nothing assigned so just assign your key binding to it.

  2. Annotations can help with displaying it in the sidebar

  1. 在搜索字段中的首选项/常规/键类型中创建一个快捷方式:“在文件中查找文本”默认情况下,它没有分配任何内容,因此只需将您的键绑定分配给它。

  2. 注释可以帮助在侧边栏中显示它

enter image description here

在此处输入图片说明

回答by wangf

Use file search to search selected resource can highlight same word in single file.

使用文件搜索来搜索所选资源可以突出显示单个文件中的相同单词。

回答by Sairam Krish

Another useful eclipse plugin is eclipse instasearch. It has extensive feature set. This is also available in eclipse marketplace.

另一个有用的 eclipse 插件是eclipse instasearch。它具有广泛的功能集。这也可以在 eclipse 市场中获得。

回答by Kislingk

There are other options needed to enable.(Preferences > General >Editors>Text Editors > Annotations). Find Occurrences and WriteOccurrences and enable Text as 'Hightlight'

还需要启用其他选项。(首选项 > 常规 > 编辑器 > 文本编辑器 > 注释)。查找 Occurrences 和 WriteOccurrences 并启用 Text as 'Hightlight'

回答by ankit

Window > Preferences > Java > Editor > Mark Occurrences

窗口 > 首选项 > Java > 编辑器 > 标记出现次数

回答by wendy

Have tried all of the above answer, but all not working. At the end, i found that it's due to i have accidentally remove some of the JRE System Library, after add back, it's work correctly

已经尝试了上述所有答案,但都不起作用。最后发现是因为我不小心删除了一些JRE系统库,添加回来后,它工作正常