Eclipse mark occurrences doesn't mark all occurrences - eclipse

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

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.

Netbeans 7.0.1 Word Wrap

I know there are a bunch of posts about this already, stackoverflow: word wrap in netbeans, for one, and there are some people that say it is already included in netbeans 7, but for the most part they are all old, or inconclusive. I use netbeans 7.0.1 and the included word wrap is half-assed and glitchy at best. Going to Tools > Options > Editor > Formatting > Line Wrap and setting it to either "After Words" or "Anywhere" both result in practically the same sort of wrapping and neither one is very reliable. On occasions it will wrap as expected, but more often than not you can end up with anywhere from one word to an entire paragraph past the vertical scrollbar. Is there something I am missing or is that really the way that's supposed to work?
I'm still looking and will post any significant finds, but does anyone know of a way to fix this, or a plugin to install for it, or anything? I would have figured after 4 years of inquiries (2008 is the oldest post I've found about this) netbeans would have fixed it :(
BTW: Not looking for reasons why my code shouldn't be more than 80 character long, there's no helping it sometimes and that answer isn't helpful. I have also tried adding "-J-Dorg.netbeans.editor.linewrap=true" in the netbeans.conf file, but from what I gather that is for enabling the feature in older version and did nothing in mine (I removed it).
On Netbeans 7 and 8, you can use Tools/Options/Editor/Formatting/LineWrap.
It can only be globally enabled.
you can do it from:
1) Tools -> Options -> Editor -> Formatting(Tab)
2) Select Your Language in "Language Drop down"
3) Select "Wrapping" from "Category and do what ever you want
Note: this is for Windows OS
I have done it in netbeans 8.0
Goto -> Tools-> options-> Editor-> Formatting-> language(dropdown-All languages) -> Category(dropdown-Tabs and indents) -> Line wrap(After word)
Make sure you re-open the file to see the change.
In case any one is looking for this with NetBeans 8 on OSX and ends up here, it's preferences/Options/Editor/Formatting/LineWrap
you can do it from:
1) Tools -> Options -> Editor -> Formatting(Tab)
2) Select Your Language in "Language Drop down"
3) Select "Tabs and Indents" from "Category
4) Dropdown" select any of the desired option from "Line Wrap drop down"
i.e After words or Anywhere
Note: this is for Windows OS
In Netbeans 7.2 it's actually, "Wrapping" instead of "Line Wrapping" and it's "If Long" instead of "After Words", but that probably doesn't answer your question.
You posted this almost one year ago, and you still haven't found anything yet?
I don't like how they decide to wrap by way of creating actual new lines in the editor. I would prefer if it just line-wrapped but you didn't have to make a new line - like, what you have with Notepad. However, I would prefer if you had a symbol to show that you're line wrapping on the next line, like I have seen in other IDE's before.
I done in Netbeans 8.0.2 as following way :
NetBeans->preferences/Options/Editor/Formatting/LineWrap
Hope this is useful.

Configure Eclipse word-boundaries so 'Next-Word-Key' skips whole identifier

If I have a piece of Code
MyIdentifierIsNice(OtherThingAlsoNice isBetterThen);
I'd like to change the behavior of Ctrl-Left in Eclipse from stopping here:
My|Identifier|Is|Nice|(|Other|Thing|Also|Nice is|Better|Then|);|
to here:
MyIdentifierIsNice(|OtherThingAlsoNice |isBetterThen);|
...or at least just not so often. Other variants would be also fine, like:
MyIdentifierIsNice|(|OtherThingAlsoNice| isBetterThen|);|
Mainly it should stop considering a CamelCaseIdentifier to consist of several words for navigation via Next-Word, and such like.
I use SpringSourceSuite Version 2.5.1, which is Eclipse 3.6, I guess.
Try and unselect the option:
Preferences / Java / Editor / Smart caret positioning in Java names
And see if that enhances the user experience in term of cursor positioning.
If this is not Java, you have a similar option in:
Preferences / General / Editors / Text Editors / Smart caret positioning at line start and end
It is usually selected, meaning if the cursor still stops at every word, that may suggests another setting for a specific language is overriding it.
Coming to Eclipse from XCode, I found the default navigation annoying. In Eclipse, Alt+Left and Alt+Right move to the next camelcase segment, and Ctrl+Left/Right does nothing. In XCode, Alt+Left/Right moves between words and Ctrl+Left/Right moves between camelcase segments. This allows you to control how fine-grained your navigation is.
How I fixed this for myself was by going into Preferences > General > Keys, searching for "Word", and changing the "Next Word" and "Previous Word" bindings from Alt+Left/Right to Ctrl+Left/Right. Then the Alt-navigation is by word and the Ctrl-navigation is by camelcase segment, as in XCode.
I thought this might be useful to some.
Edit:
As I continue to use these new settings, I've found another point:
Although navigation works as advertised, selection has some funky behavior. Namely, Shift+Ctrl+Left/Right can sometimes select large blocks of text instead of just the next camelcase component.
To fix this, again go to Preferences > General > Keys, search for "Select".
Set "Select Next/Previous Word" to Shift+Ctrl+Right/Left.
Unbind "Select Next/Previous Element" (there are three "Whens" to pick from, I unbound all 3).
Voila.
If you want a very simple way to select a entire word without the need to disable smart caret positioning.
You can use at the beginning of word or inside the word:
Shift+Alt+Right
At the end or in the middle of word:
Shift+Alt+Left

Is there a way to fold eclipse sub-blocks like an "if" statement?

Currently Eclipse only fold the java doc and at function level, but when reading long methods, there could be quite a lot of if/else etc, is there a way to fold them?
I found the Coffee-Bytes plugin. I downloaded it from this link and found this guide by the author, for using it.
You can find more details in these references:
What code folding plugins work on Eclipse 3.6?
How to use Coffee-Bytes code folding
in updated versions of Eclipse
Change folding preferences at:
Window -> Preferences -> C/C++ -> Editor -> Folding -> Enable folding of preprocessor branches (#if/#else)
Enable folding using ctrl + shift + /
No, in the Preferences Dialog (Menu Window/Prefernces): Java/Editor/Folding you may choose,
Comments
Head Comments
Inner Types
Members and Imports
if Enable Folding is checked.
If you wan't to do this because the blocks are so long that can't reconize the structure
you should consider to split if/else blocks into methods using Alt-Shift-M (Extract Method)
It appears Eclipse does not have built-in support for folding if/else statements but allows folding for other more complex cases like Anonymous inner classes. Try looking for plugins like this one (last modified 2007, try it if it supports your Eclipse version).
Ok, this is a little bit older, but maybe someone could find this useful:
In most cases you can surround the piece of code by an additional pair of scope brackets, and to remember what you folded you can add a line comment.
For example, if you want to collapse the following:
int SectionA_var1;
int SectionA_var2;
int SectionA_var3;
int SectionA_var4;
int SectionA_var5;
int SectionB_var1;
just add the brackets an the comment:
{ // SectionA
int SectionA_var1;
int SectionA_var2;
int SectionA_var3;
int SectionA_var4;
int SectionA_var5;
}
int SectionB_var1;
Then you get the (-) sign and you can collapse the whole section to this:
{ // SectionA[...]
int SectionB_var1;
No plugin necessary, and until now I had no situation where this gave me any downsides, except that you cannot use it on a top level declaration to collapse methods.
For now, there is built-in function.
Click "Window->Preferences->C/C++->Editor->Folding" and then enable appropriate option you want.
Apply, close and either refresh project or reopen eclipse.
As weird as it looks like, sounds like developers never thought about that. if you have a big if statement or any switch/loop ... just use notepad++ to be able to fold/unfold
For Python, i.e. Eclipse/PyDev, go to Windows > Preferences > PyDev > Editor > Code Folding and check all the boxes.
Fold java source code like "if else for" statement
install pluins com.cb.eclipse.folding
restart your Eclipse make sure the pluins enabled
Click "Window->Preferences->Java->Editor->Folding"
Select folding: select "Coffee Bytes Java Folding"
Switch to "User Defined Regions"
"Start Identifier" = { ; End Identifier = }
click "Apply and Close"
Reopen java source editor you will see "if" or "for" block is collapsable

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)