问题
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. 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.
回答1:
You can try to activate Toggle Mark Occurrences with icon on Toolbar:
回答2:
Preferences --> Java --> Editor --> Mark Occurrences
回答3:
In General > Editors > Text Editors > Annotations
回答4:
Check out options that are checked in Preferences -> Java -> Editor -> Mark occurrences. Then restart Eclipse.
回答5:
Find the Preferences
under Window
,
In General > Editors > Text Editors > Annotations
(1)
(5) is to select the color and press apply.
回答6:
The standard "Mark Occurrences" functionality included in Eclipse that everyone recommends only highlights identifiers in editors of whatever language. For example, it won't highlight int
in C editors, and it won't help at all in the Console pane.
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.
As of November 2017 Glance works for Eclipse Neon and Oxygen. There was a period of time in which Neon was unsupported, and a fork appeared, but it seems unnecessary now (and abandoned).
回答7:
Go
Java> Editor > Mark Occurrences
Uncheck "Keep Marks when the section changes" then click Ok
Restart Eclipse.
This work for me.
回答8:
For Eclipse Mars:
Window --> Preferences --> Check (Mark occurrences of the selected element in the current file.)
As shown if figure:
回答9:
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.
回答10:
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
. Mine was defaulted to black, which does not stand out on a black background.
回答11:
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. Second is using a plugin called Glance which is available in Eclipse marketplace. This is supereasy and effective.
First Method
In the toolbar, there is button for 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.
You can also go to Window
==> Preferences
==> Java
==> Editor
==> Mark Occurrences
==> Check all the checkboxes.
Restart Eclipse and check if highlighting works. If still doesn't work, then Go to Second Method
Second Method
From Eclipse marketplace, install Glance
. Once installed, restart Eclipse.
Now select any word in your eclipse editor
- Move focus to component where you want to search
- Open Glance using
Ctrl + Cmd + F
shortcut on Mac orCtrl + Alt + F
on other platforms - Enter text you want to search
- Use
Enter
or**Shift + Enter**
to find next/previous match - Close search box using
Esc
You can also customize Glance fromWindow
==>Preferences
==>Glance
回答12:
- Click the word and hold until a popup appears as shown in the figure.
- On the popup, there is a little right arrow, after clicking it, a new icon shows up.
- Click that link to open
preferences
. - Once in
preferences
, selectC/C++ Occurrences
(it will be language specific) and selectInclude in next/previous navigation
withText as Highlighted
.
This should enable the feature of highlighting all occurences of the selected word in the opened file.
来源:https://stackoverflow.com/questions/10310597/cannot-highlight-all-occurrences-of-a-selected-word-in-eclipse