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

发布于 2024-12-01 19:13:54 字数 279 浏览 7 评论 0原文

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

在此处输入图像描述

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

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

enter image description here

Is there any ways 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).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

吐个泡泡 2024-12-08 19:13:54

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

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

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

如果有什么事情发生,我非常感谢您在这里分享它,多年来我一直在尝试在 Eclipse 中进行适当的突出显示,但没有成功...:)

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

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.

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... :)

风向决定发型 2024-12-08 19:13:54

这是 eclipse 的一个插件: http://ystrot.github.io/glance/

它突出显示所有出现的情况,就像使用记事本++一样按 Ctrl + Alt + F。

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

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

小镇女孩 2024-12-08 19:13:54

以下是我发现对我有用的方法,但您也可以为“在文件中查找文本”指定一个快捷键:

  1. 选择单词或文本部分
  2. CTR+3 激活“快速访问”搜索
  3. 类型“在文件中查找文本”
  4. 执行

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

eclipse-highlight-search-results-in-file

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+3 to activate 'Quick Access' search
  3. Type 'Find Text in File'
  4. Execute

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

eclipse-highlight-search-results-in-file

荆棘i 2024-12-08 19:13:54

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

  1. 在“首选项/常规/按键”中创建快捷方式
    在搜索字段中输入:“在文件中查找文本”
    默认情况下,它没有分配任何内容,因此只需为其分配键绑定即可。

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

在此处输入图像描述

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

enter image description here

孤寂小茶 2024-12-08 19:13:54

如果您启用“标记出现次数”(Alt + Shift + O),则所有与您标记的单词相同的单词都会突出显示。

在此处输入图像描述

If you enable "Mark Occurrences" (Alt + Shift + O), then all words that are the same as the one you have marked will be highlighted.

enter image description here

遗心遗梦遗幸福 2024-12-08 19:13:54

好吧,如果您仅在当前打开的文件中搜索(通过 CTRL-F),那么不行,您不能突出显示所有内容。

但是,如果您使用高级搜索(CTRL-H,然后转到“文件搜索”选项卡),您可以输入搜索模式,以及应搜索的文件的文件名模式,以及何时搜索搜索完成,搜索词在找到它们的每个文件中突出显示:

在此处输入图像描述

Well if you're searching in the currently open file only (via CTRL-F) then no, you can't have everything highlighted.

However if you use the advanced search (CTRL-H, then go to "File search" tab) there you can input the search pattern, as well as the file-name pattern for the file(s) where it should search, and when the search is done, the search terms are highlighted in each file where they were found:

enter image description here

北座城市 2024-12-08 19:13:54

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

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

陌若浮生 2024-12-08 19:13:54

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

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

诺曦 2024-12-08 19:13:54

还需要启用其他选项。(首选项 > 常规 > 编辑器 > 文本编辑器 > 注释)。查找 Occurrences 和 WriteOccurrences 并将文本启用为“突出显示”

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

深府石板幽径 2024-12-08 19:13:54

已尝试以上所有答案,但均无效。最后,我发现这是由于我不小心删除了一些JRE系统库,添加回来后,它可以正常工作

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

┼── 2024-12-08 19:13:54

窗口>首选项>爪哇>编辑>标记出现次数

Window > Preferences > Java > Editor > Mark Occurrences

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文