简体   繁体   English

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

[英]Cannot highlight all occurrences of a selected word in Eclipse

I tried using the Toggle mark occurrences (Alt + Shift + O) button and also in Preferences -> General -> Editors -> Text Editor -> Annotations and setting the C/C++ Occurrences and C/C++ Write occurrences.我尝试使用Toggle mark occurrences (Alt + Shift + O)按钮以及Preferences -> General -> Editors -> Text Editor -> Annotations并设置 C/C++ 出现次数和 C/C++ 写入出现次数。 But still when I select a word it won't highlight all occurrences of that specific word.但是当我选择一个单词时,它不会突出显示该特定单词的所有出现。

What I am using is Eclipse Indigo Service Release 2 in XP, with a C++ project.我使用的是 XP 中的 Eclipse Indigo Service Release 2,带有一个 C++ 项目。

You can try to activate Toggle Mark Occurrences with icon on Toolbar:您可以尝试使用工具栏上的图标激活 Toggle Mark Occurrences:日食工具栏

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

In General > Editors > Text Editors > Annotations在“ General > Editors > Text Editors > Annotations

在此处输入图片说明

Check out options that are checked in Preferences -> Java -> Editor -> Mark occurrences.查看在首选项 -> Java -> 编辑器 -> 标记事件中选中的选项。 Then restart Eclipse.然后重新启动 Eclipse。

The standard "Mark Occurrences" functionality included in Eclipse that everyone recommends only highlights identifiers in editors of whatever language.每个人都推荐的 Eclipse 中包含的标准“标记出现”功能仅在任何语言的编辑器中突出显示标识符 For example, it won't highlight int in C editors, and it won't help at all in the Console pane.例如,它不会在 C 编辑器中突出显示int ,并且在控制台窗格中根本没有帮助。

So if you want to highlight ALL occurrences on ANY word in ANY Eclipse pane (kinda like Notepad++ does), try the Glance plug-in for Eclipse .因此,如果您想突出显示任何 Eclipse 窗格中任何单词上的所有匹配项(有点像 Notepad++ 那样),请尝试EclipseGlance 插件

As of November 2017 Glance works for Eclipse Neon and Oxygen.截至 2017 年 11 月,Glance 为 Eclipse Neon 和 Oxygen 工作。 There was a period of time in which Neon was unsupported, and a fork appeared , but it seems unnecessary now (and abandoned).有一段时间 Neon 不受支持,出现了一个叉子,但现在似乎没有必要(并被放弃)。

Find the Preferences under Window ,Window下找到Preferences

主窗口 - 选项卡

In General > Editors > Text Editors > Annotations (1)General > Editors > Text Editors > Annotations (1)

(5) is to select the color and press apply. (5) 是选择颜色并按应用。

首选项窗口

For Eclipse Mars:对于日食火星:

Window --> Preferences --> Check (Mark occurrences of the selected element in the current file.)窗口 --> 首选项 --> 检查(标记当前文件中所选元素的出现。)

As shown if figure:如图所示:

在此处输入图片说明

Go

Java> Editor > Mark Occurrences Java> 编辑器 > 标记出现次数

Uncheck "Keep Marks when the section changes" then click Ok取消选中“部分更改时保留标记”,然后单击“确定”

Restart Eclipse.重新启动 Eclipse。

This work for me.这对我有用。

There are two ways to highlight all occurences.有两种方法可以突出显示所有事件。 First is using Eclipse options, which is not very reliable, because in many versions of Eclipse it is not supported.首先是使用 Eclipse 选项,这不是很可靠,因为在许多版本的 Eclipse 中它不受支持。 Second is using a plugin called Glance which is available in Eclipse marketplace.其次是使用名为Glance的插件,该插件可在 Eclipse 市场中获得。 This is supereasy and effective.这是超级简单和有效的。

First Method第一种方法

In the toolbar, there is button for Toggling Mark Occurrences .在工具栏中,有用于Toggling Mark Occurrences按钮。 So, once you selected the text/word whose occurences you wish to highlight, then click this toggle button.因此,一旦您选择了要突出显示其出现的文本/单词,请单击此切换按钮。

在此处输入图片说明

Let's say this step doesn't work for you.假设这一步对您不起作用。 Then, Follow this step: Goto: Window ==> Preferences ==> General ==> Editors ==> Text Editors ==> Annotations ==> On right Annotations types box: Occurrences ==> Select all check boxes.然后,按照以下步骤操作:转到: Window ==> Preferences ==> General ==> Editors ==> Text Editors ==> Annotations ==> 在右侧的注释类型框: Occurrences ==> 选择所有复选框。 在此处输入图片说明

You can also go to Window ==> Preferences ==> Java ==> Editor ==> Mark Occurrences ==> Check all the checkboxes.您还可以转到Window ==> Preferences ==> Java ==> Editor ==> Mark Occurrences ==> 检查所有复选框。 在此处输入图片说明

Restart Eclipse and check if highlighting works.重新启动 Eclipse 并检查突出显示是否有效。 If still doesn't work, then Go to Second Method如果仍然不起作用,则转到第二种方法

Second Method From Eclipse marketplace, install Glance .第二种方法 从 Eclipse 市场,安装Glance Once installed, restart Eclipse.安装后,重新启动 Eclipse。 Now select any word in your eclipse editor现在在 Eclipse 编辑器中选择任何单词

  1. Move focus to component where you want to search将焦点移至要搜索的组件
  2. Open Glance using Ctrl + Cmd + F shortcut on Mac or Ctrl + Alt + F on other platforms在 Mac 上使用Ctrl + Cmd + F快捷键或在其他平台上使用Ctrl + Alt + F打开 Glance
  3. Enter text you want to search输入要搜索的文字
  4. Use Enter or **Shift + Enter** to find next/previous match使用Enter**Shift + Enter**查找下一个/上一个匹配项
  5. Close search box using Esc使用Esc关闭搜索框在此处输入图片说明 You can also customize Glance from Window ==> Preferences ==> Glance您还可以从Window ==> Preferences ==> Glance自定义Glance

If you go into the window-prefrences, select the language you want/are working with.如果您进入窗口首选项,请选择您想要/正在使用的语言。 Select the editor under this specific language and then there is a mark occurrences there that has some options.选择此特定语言下的编辑器,然后有一个标记出现,其中有一些选项。 Where it says keep marks when the selection changes, for me this was checked.在选择更改时保留标记的地方,对我来说已选中。 When I unchecked it the system started highlighting correctly.当我取消选中它时,系统开始正确突出显示。

For folks who are using a dark background with light font colors, you may want to check out the highlight color in Preferences -> General -> Editors -> Text Editor -> Annotations .对于使用深色背景和浅色字体的人,您可能需要查看Preferences -> General -> Editors -> Text Editor -> Annotations的突出显示颜色。 Mine was defaulted to black, which does not stand out on a black background.我的默认为黑色,在黑色背景上不会突出。

Glance does not work anymore, but in current Eclipse Versions (Eclipse 2020) you can highlight any word by selecting the word and pressing CTRL+F . Glance 不再起作用,但在当前的 Eclipse 版本 (Eclipse 2020) 中,您可以通过选择单词并按CTRL+F来突出显示任何单词。 The word is now highlighted.现在突出显示该词。 In the small search input, you can toggle 'match whole word' and case sensitivity.在小型搜索输入中,您可以切换“匹配整个单词”和区分大小写。

I'd like to complement the other answers - which work in Java editor only or require plugins - with a way to highlight all occurrences of any text (not just a word or identifier) in any editor of text files (eg SQL, CSV, HTML, TXT, Java, etc ...).我想补充其他答案 - 仅在 Java 编辑器中工作或需要插件 - 用一种方法突出显示任何文本文件编辑器(例如 SQL、CSV、 HTML、TXT、Java 等...)。

There is a standard/built in command called Find Text in File (under Window -> Preferences -> Keys )有一个名为Find Text in File的标准/内置命令(在Window -> Preferences -> Keys

在此处输入图片说明

By default it has no keyboard shortcut assigned.默认情况下,它没有分配键盘快捷键。 Simply give it a shortcut (eg Ctrl + Alt + S ) select some text (not necessarily a word) and it will find and highlight all occurrences of that selected text.只需给它一个快捷方式(例如Ctrl + Alt + S )选择一些文本(不一定是单词),它就会找到并突出显示该选定文本的所有出现。

It can also be invoked from the menu as Search -> Text -> File .它也可以从菜单调用Search -> Text -> File
Enjoy 🙂享受🙂

  1. Click the word and hold until a popup appears as shown in the figure.单击单词并按住直到出现如图所示的弹出窗口。
  2. On the popup, there is a little right arrow, after clicking it, a new icon shows up.在弹出窗口中,有一个向右的小箭头,点击后会出现一个新图标。
  3. Click that link to open preferences .单击该链接以打开preferences
  4. Once in preferences , select C/C++ Occurrences (it will be language specific) and select Include in next/previous navigation with Text as Highlighted .进入preferences ,选择C/C++ Occurrences (它将是特定Include in next/previous navigation语言的)并选择Include in next/previous navigation with Text as Highlighted

This should enable the feature of highlighting all occurences of the selected word in the opened file.这应该启用在打开的文件中突出显示所选单词的所有出现的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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