Eclipse highlighting the same occurrence of the word - eclipse

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

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

Here is a plugin for eclipse: http://ystrot.github.io/glance/
It highlights all occurrences as with notepad++ upon hitting Ctrl + Alt + F.

Below is what I found works for me but you can also assign a key shortcut to 'Find Text in File':
Select the word or section of text
Press CTR+3 to activate 'Quick Access' search
Type 'Find Text in File'
Execute
As mentioned by #Kislingk you can modify how the words are highlighted/marked in 'Preferences > General >Editors>Text Editors > Annotations'.

Here is the closest solution I have found:
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.
Annotations can help with displaying it in the sidebar

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

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:

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

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

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

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

Window > Preferences > Java > Editor > Mark Occurrences

Related

Eclipse (Squish) add custom annotation types

Hay, has anybody experiences with adding custom annotation types or appearance color options to the eclipse squish IDE? I'm trying to find a way to highlight previously verbalized words in the editor (i.e. **markme_**something(parameter). Sadly I can't find any plugins and as far as I noticed squish is doing a good job to hamper any kinds of external not former installed or in the manual mentioned plugins.
Another of my thoughts are to write an addition to the syntax checker but that would be probably kinda over the top and not that easy to realize. The source code is written in python.
Greetings and thanks!
Eduard
To mark a search string in the editor you can use Search > Search... (Ctrl+H). Then just enter the search string and press Enter. (While this will open and populate the "Search" view, the search string occurrences are being marked in the editor anyway.)
Perhaps you are trying to let the script editor color (a customizable set of) substrings in a customizable way? I have not found an Eclipse plug-in that would achieve that. The closest I could find (and available in source code form) is Highlight On Selection.
PS: Note that custom plug-ins are not supported in the Squish IDE, but that you can use the Eclipse IDE Integration, and then install the desired plug-ins into this Eclipse installation.

How can I keep Eclipse from filling in auto-completions when I type an opening parenthesis ('(')?

So, on Eclipse Luna, I often encounter the situation where I'm typing a method name, but the first autocomplete suggestion is not the method I am looking for but something that is prefix-equivalent but longer, as in this example:
In the example, I just wanted the element(String name) method, so instead of hitting Return, I type ( instead. The result, quite annoyingly, is this:
This is clearly not what I was looking for. Is there a way to prevent Eclipse from performing auto-complete when I hit open-parenthesis (()?
These are my content assist settings (aparrently, I don't have code recommenders installed at all in this eclipse installation):
In Eclipse 4.11 (2019-03), and possibly earlier, the answer to this is under Preferences → Java → Editor → Content Assist → Disable insertion triggers except 'Enter'. After I checked that box, editing became a lot less annoying.
I have no idea why Eclipse doesn't do it by default. Who types map.put( and wants that to autocomplete to map.compute()?
A hack for this is to change the way Eclipse sorts the proposals.
You can go to Preferences menu and then go to the section for which you want to edit sorting. Then to de Editor section and Content Assist.
For example, for Java editor, it will be Preferences > Java > Editor > Content Assist.
There you will see, more or less in the middle of the window, a section called Sorting and filtering. Inside there is an option called Sort proposalswhich you can change from by relevance to alphabetically. Save an close.
With this you will get the proposals list order alphabetically and element() will be before other methods starting by element.
EDIT:
Tested in Eclipse Luna running in Ubuntu 14.04 and it works. You'll still get your code completed when writing ( but it will be completed with the shorter option available in the proposals list. If you want to use another method, you can continue writing some letters and the shortest option will disapear of proposals as it doesn't match what you are writing.
I guess your problem is the substring matches.
Go Window->Preferences->Java->Editor>Content Assist.
In Sort proposals section uncheck Show substring matches.
I found By relevance more useful then Alphabetically.
I have usually checked hidden Hide proposals not visible in the invocation target, and Hide deprecated references, too.
I hope it help.
The feature you're fighting with is the new "Intelligent code completion" which orders methods based on average usage count. Don't ask me where they get the data. See also here:
http://www.eclipse.org/recommenders/manual/#intelligent-code-completion
To disable the feature go to the preferences page Code Recommenders|Completions and uncheck "Enable intelligent code completion".
Another issue which might negatively affect code completions appears to be 'Java Proposals (Task-Focused)'. For example, it causes map.put() to be replaced with map.compute().
You can disable these from Preferences | Java | Editor | Content Assist | Advanced.
See also: http://literatejava.com/eclipse/bad-auto-completions-in-eclipse/

How to replace Eclipse search dialog?

Is it possible to replace Eclipse search dialog to something more convenient, like the search dialog in Firefox or Chrome? The default one doesn't support F3 to search for the next match, it doesn't move itself away if the match is underneath the box and doesn't allow to highlight all the matches - and these are the features I really miss...
I don't think you can replace the Find dialog easily. You would probable need to (re-)write parts of Eclipse. Definitely doable, but not a small task...
That said, most of your problems can probably be addressed by the current dialog:
The default one doesn't support F3 to search for the next match
"search next match" is Ctrl-K by default. You can configure the keybindings under "Preferences / General / Keys": change the keybinding for "Find Next".
it doesn't move itself away if the match is underneath the box
Yes, that would be nifty. The dialog does however remember where you last put it, so just put it somewhere out of the way (e.g. over the package browser, or to the right), and it will stay there.
and doesn't allow to highlight all the matches
This is not yet available (though it has been discussed: https://bugs.eclipse.org/bugs/show_bug.cgi?id=29692 ). There are however two ways of getting a similar result:
Use the search function from the toolbar ("File Search" from the "torch" button). If you search there, it will highlight all matches in the editor (and provide marks in the editor ruler, and a list in the search view).
For Java elements, activate "Mark Occurences" ("highlight pen" button). This will highlight all occurences of a Java element if you mark in in the editor.
Maybe one of these will help you.
Finally, you can just open any file in an external editor (like (g)vim or Notepad++) right from inside Eclipse (right-click -> Open with). Then you can use any editor you want...
While it may not be exactely what you want, have you ever used the incremental search (Ctrl + J)? In my opinion it is much more convenient than the standard search.
A newer alternative is InstaSearch.
Information:
InstaSearch is an Eclipse plug-in for doing fast text search in the workspace. The search is performed instantly as-you-type and resulting files are displayed in an Eclipse view. It is a lightweight plug-in based on Apache Lucene search engine.
Each file then can be previewed using few most matching and relevant lines. A double-click on the match leads to the matching line in the file.
The "search the next match" is Ctrl-K. Previous is also available, see the "Edit" menu...
Only the highlight feature does not seem to be present. You might need a plugin for that (everythinhg is possible with plugins).
There was a Summer of Code project to implement a Firefox like search in Eclipse in 2007.
This is the official page, and this Blog shows a promising screenshot.
I never tried to install it, and I didn't find a final release or something though :(
SearchTab is an Eclipse plugin that shows a Firefox-like search tab
You do this by changing the key bindings under Preferences -> General -> Keys

String search: has Eclipse IDE got a modern "find" UI (a la Firefox)

One thing really really annoys me about the Eclipse ide: its find UI is so old style.
I would much prefer something like Firefox or Safari, that doesn't clutter my screen real estate with a useless window.
(source: eclipse-blog.org)
Press ctrl+j. Is that what you want?
Hold down shift to go backwards.
you can also select the word you want to search and use ctrl+K, use shift to go backwards.
And, if Eclipse's incremental search is not enough, you could always use a plugin like Glance.From their site:
Glance is an Eclipse plug-in providing extensible useful incremental text search in Eclipse. This plug-in supports the following features:
highlight all found matches
background search which never blocks text box
search in tables and trees
update matches when target content changed
new text containers can be supported through extension points
a lot of search settings
You mean, like... Ctrl+F, and then Ctrl+K?
You don't have to use the Search menu.
On the other hand, if you just don't like the popup dialog, I think you're SOL for now.
The Eclipse "find" dialog does more than "find" on browsers you mentioned (e.g. search-and-replace, etc.) Having more options means more real estate to control them.

PHPEclipse weird highlight

This is not a technical problem, but very annoying.
Does anyone know how to turn off or change the color for the name highlight in phpEclipse?
I use white-on-black scheme and this highlight has a white background which makes it unreadable and very ugly.
To better explain which highlight I'm refering to, it's when I move the cursor to a variable/function/method/constant, all other places that name is typed get highlighted.
I've spent a few days going thru the settings many, many times and I haven't found one that changes that specific annoying highligh.
Anyone? please? :)
For Java in Eclipse it is:
Window > Preferences > Java > Editor > Mark Occurrences.
My ruby plug-in has the same option. Do a search in the preferences window for 'Mark Occurrences' and hopefully the php plug-in has the same option.
Thanks, that was it, Mark Occurences.
When I searched thru the options I was looking for color pickers instead of checkboxes :)
It would be nicer to be able to change the highlight color for that, but even removing it is of huge help.
From Eclipse, go to Window > Preference, use the filter field ("type filter text") to search for "color". It will show all the config options related to the colors.
I suppose it's not a problem with phpEclipse, but an incompatibility with another Eclipse plugin.
PS: When you fix the problem please tell us what that setting!