Eclipse editor show variable occurrence - eclipse

In Eclipse Standard Installation the editor marks all occurrences of a variable if you click on it with a cursor.
e.g. Setting the cursor somewhere on the 'foo' Variables it highlights all other foo's too.
public void printString(String foo){
System.out.println(foo); }
Any ideas where to switch this behavior on again or why the feature doesn't work ?
I know the workaround is 'References->Workspace' but the auto highlighting is much more convenient.

You are asking about the "Toggle Mark Occurrences" the short cut for this is Alt + Shift + O

You can also enable it from
Window > Preferences > Java > Editor > Mark Occurrences

Related

eclipse multiple text selection like sublime text 2

is there an option or plugin for eclipse which would enable multiple simultaneous selections in the same editor.
In sublime text, selecting some text and then pressing Ctrl+d will add next instance of the same text to the selection if possible. After selecting the instances needed the editor has multiple carrets (not necessarily on the same or adjacent columns and rows). In this mode it is possible to move all cursors forward or back simultaneously and to edit all instances of text simuntaneously.
I find this feature very usefull and miss it sorely in eclipse..
This Eclipse plugin attempts to provide this feature: https://github.com/caspark/eclipse-multicursor. From the README:
What is this?
A work-in-progress attempt to provide Sublime-Text-like
multi cursor support for text editors in the Eclipse IDE.
What works?
Multiple identical lines can be edited simultaneously using Eclipse
linked mode editing (similar to existing "rename in file"
functionality)
Next steps
"select next" functionality + associated editing using Eclipse linked
mode
"find next" + associated editing
editing of non-identical text / editing without using linked mode
split selection to lines
regexp support for find next
This feature is available in LiClipse.
See it in action (more towards the end of the video).
It supports linking with Ctrl+K, unlink with Shift+Alt+K, Ctrl+Alt+mouse double click to select words or Ctrl+Alt+Mouse to make a selection of a region (or just end lines).
Preferences>General>keys>Rename - refactoring
I changed the binding to command + shift + R when > Editing Text.
Sorry for bringing up an old question, stumbled upon it after searching google for the problem
Alt + Shift + A, then you can hold shift and use the cursor in multiple lines.
Like Ctrl+D I could not find, but like Alt+F3 in sublime (multiselects all matches), you can do by pressing Alt+Shift+R, or select text > right click > refactor > rename.
Must say that this does not work with any kind of text. It works with names of variables, functions, classes etc.
Tested on Eclipse 3.8.1
ALT + SHIFT + F worked for me.
You can see shortcuts for all here:
Goto -> Window -> Preferences -> General -> Keys and search for replace then you will see binding for Find and replace. In the bottom of that window, you can add your key to Binding text box. There you can add or edit any keys as shortcut.
If you want to replace selected word's matching words or find selected words, use below keys because you do not need to select all words in eclipse:
Ctrl+F gives me Find/Replace dialog box.
Or you can,
First Alt+A
Next Alt+F
Then press on Replace or Search button occurding to your need.

Eclipse mark occurrences doesn't mark all occurrences

Just installed Eclipse Juno Release, Build id: 20120614-1722.
I have 'Mark Occurrences' turned on, and I can see that it does indeed mark some of the occurrences in the JS file I'm editing. However, there's a function call that it doesn't mark.
var trackView = function() {
saveData();
},
saveData = function() {
// do something
};
When I click into the saveData occurrence where it is defined (line 4), it highlights, but it doesn't highlight the occurrence on line 2 where the function is being called. When I click into the saveData occurrence on line 2, neither highlights.
Any ideas?
The bug report in Eclipse also mentions another workaround: select something in the Outline view, and then select the field in your source again.
This works mostly always for me.
If you toggle from eclipse window to another window using ATL+TAB and come back to Eclipse window it is higlighted.
This is a known bug in Eclipse Juno and is actively (as of this writing) being investigated by Eclipse developers.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=400661
https://bugs.eclipse.org/bugs/show_bug.cgi?id=398509
UPDATE 6/2: This bug has been resolved in Release 4.2.2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=398509
If you uncheck the below option it will work fine
Preference > Java > Editor > Mark Ocurrences > Uncheck: Keep marks when the selection changes.
This is a bug in Eclipse - the occurrence-highlight seems to "stick" to the first thing you point to.
Two "solutions" that at least get the highlight stuck on a new item (!!):
As #Subas Raj mentioned, defocus and refocus the window - when you come back, your current position is occurrence-highlighted. Either hit AltTab twice, or use your mouse to click/focus some other window, then back.
As #Leo and #Gorky mentions, hit AltShiftO twice. This is the shortcut for toggling highlight occurrences, and when you turn it back on, your current position is occurrence-highlighted.
And finally, a third ACTUAL solution: Replace one specific jar with a patched one: https://bugs.eclipse.org/bugs/show_bug.cgi?id=398509#c60
.. or upgrade to M7 (4.3), which now are released: https://bugs.eclipse.org/bugs/show_bug.cgi?id=398509#c62
All configuration and settings for "Mark Occurrences" are proper but it seems this is Eclipse JUNO problem.
I have been observing this issue and tried to resolve many way but in Juno, highlighting occurrences is not consistent.
Sometimes it works pretty fast, sometimes it takes time to highlight, sometimes it doesn't at all.
Also observed that once we restart Eclipse, things works proper but gradually, highlighting occurrences become slow and stops also.
~Chirag
Go to Window -> Preferences -> General -> Editors -> Text Editors -> Annotations
Under both Occurrences & Write Occurrences, make sure you have the Text as Highlighted option selected.
Also, under General -> JavaScript -> Editor -> Mark Occurrences make sure all of the check boxes are checked.
I unchecked General -- Appearance Use mixed fonts and colors for labels and now it works better...
Same as I encountered, you can try to click "Toggle Mark Occurrences" twice (turn it off and turn on) or you can also try to use Alt+Shift+O twice.
And can also try the solution of #Subas Raj, is good.
For now there is only workaround (push "Alt + Shift + O" twice):
Cannot highlight all occurrences of a selected word in Eclipse

How can I make Aptana/Eclipse replace selected text with quotes?

When selecting a portion of text in Aptana Studio (I assume the same is true for Eclipse in general) like so:
And then typing a single quotation mark ("), it will result in this:
But what I want is this:
Or even better:
Please note, I really like automatic closing of parenthesis/quotation marks/braces/..., I just want to affect the behavior when text is selected.
In Aptana Studio 3:
Window > Preferences > Aptana Studio > Editors > Disable "Wrap selected text with matching characters"
This helped me find the solution: https://aptanastudio.tenderapp.com/discussions/questions/1122-disable-automatically-closing-quotes

How do I disable the formatting symbols in eclipse?

I actually can't see anything because of all the formatting symbols. I have no idea what hotkey that was but I can't find any solution how to disable those symbols. Have you any idea if there is a hotkey? I can't remember what that hotkey was ...
You can also disable them by using this button:
The command you are looking for is "Show Whitespace Characters". If you cannot find it in the toolbar or menu, the simplest way to disable it is:
press <Ctrl>-3
enter "Show Whitespace Characters"
select the command from the list with a double click or hitting
You can turn off/enable white spaces/line break by:
Window > Preferences > General > Editors > Text Editors > 'Show whitespace characters'
You can try the hotkey: ctrl + '.' (period)
But that depend of your hotkey profile.
You can on/off white spaces and line breaks the following step in eclipse.
Window → Editor → Show WhiteSpace Characters
You can also disable them by using button showing in below image:

How to Fix "Mark Occurrences" in Eclipse?

Eclipse is a great editor, and among it's many wonderful features one of my favorites is the Mark Occurrences feature. However, I recently installed the Aptana plug-in, and in trying to configure it I somehow managed to break Mark Occurrences in my Eclipse installation.
The feature still works somewhat, but instead of highlighting all occurrences of a given object, it now only highlights the occurrence where it is first created. In other words, in:
1. Dog dog = new Dog();
2. dog.bark();
3. dog.bark();
Only the "dog" in line 1 would be highlighted, not the "dog" in 2 or 3.
However, before I know I had things configured such that all three "dog" references would be highlighted by Eclipse. Does anyone know what configuration option I changed to "break" the marking of occurrences like this?
If the option mentioned by laurie is checked and you're wondering why it isn't working, you might have hit Alt-Shift-O sometime:
Cannot highlight all occurrences of a selected word in Eclipse
Note, that "Organize Imports" has Ctrl-Shift-O...
Check the following preference setting:
Preferences > General > Editors > Text Editors > Annotations
In here compare the settings for Occurrences and Write Occurrences.
You probably don't have the Text as higlighted option checked
There is another way to toggle the Mark Occurrences feature (apart from Preferences -> Java -> Editor -> Mark Occurrences)
Simply click the "Toggle Mark Occurrences" button from the toolbar. This can be seen in the image below. If you don't see the item in your bar you can turn on by selecting Window > Perspective > Customize Perspective... > Editor Presentation > Toggle Mark Occurrences
You can use a keyboard shortcut to toggle it, also:
On Windows: Alt + Shift + O
On OS X: Option + Command + O
Hope that helps
Preference > Java > Editor > Mark Ocurrences > check: Mark Ocurrences of the selected element in the current file.
and eclipse won't highlight occurences if your project contains errors
check the Problems view to be sure you project is clean
Go
Java> Editor > Mark Occurrences
Uncheck "Keep Marks when the section changes" then click Ok
Restart Eclipse.
This work for me.
Double click on the class or the package in it disappears. Have no fear.
( I also activated this feature by mistake while pressing selecting a word)