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)
Related
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.
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
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
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
How can I show line numbers by default in Eclipse?
Window → Preferences → General → Editors → Text Editors → Show line numbers.
Edit: I wrote this long ago but as #ArtOfWarfar and #voidstate mentioned you can now simply:
Right click the gutter and select "Show Line Numbers":
If this doesn't work it may be overridden by your current settings. You can right-click in the bar to the left of the code where line numbers would normally appear and turn them on with the context menu.
Update November 2015:
In Eclipse Mars 4.5.1, line numbers are (annoyingly) turned off by default again. Follow the below instructions to enable it.
Update December 2013:
Lars Vogel just published on his blog:
Line numbers are default in Eclipse SDK Luna (4.4) as of today
(December 10, 2013)
We conducted a user survey if users want to have line numbers activated in text editors in the Eclipse IDE by default.
The response was very clear:
YES : 80.07% (1852 responses)
NO : 19.93% (461 responses)
Total : 2313
Skipped: 15
With Bug 421313, Review - Line number should be activated by default, we enabled it for the Eclipse SDK build, I assume other Eclipse packages will follow.
Update August 2014
Line number default length is now 120 (instead of 80) for Eclipse Mars 4.5M1.
See "How to customize Eclipse's text editor code formating".
Original answer (March 2009)
To really have it by default, you can write a script which ensure, before launching eclipse, that:
[workspace]\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.ui.editors.prefs does contain:
lineNumberRuler=true
(with [workspace] being the root directory of your eclipse workspace)
Then eclipse will be opened with "line numbers shown 'by default' "
Otherwise, you can also type 'CTRL+1' and then "line", which will give you access to the command "Show line numbers"
(that will switch to option "show line numbers" in the text editors part of the option.
Or you can just type "numb" in Windows Preferences to access to the Text Editor part:
Picture from "How to display line numbers in Eclipse" of blog "Mkyong.com"
As simple as that.
Ctrl+F10, then N, to Show or hide line numbers.
Reference : http://www.shortcutworld.com/en/win/Eclipse.html
Slight variation on Mac OSX:
Eclipse → Preferences → General → Editors → Text Editors → Show line numbers
Windows → Preferences → General → Text Editors → Show numberlines
in this file
[workspace].metadata.plugins\org.eclipse.core.runtime.settings\org.eclipse.ui.editors.prefs
make sure the parameter
lineNumberColor=0,0,0
is NOT 255,255, 255, which is white
Go to Windows → Preferences → General → Text Editors → Show numberlines. Click OK, then Apply changes. Then it will show the line count automatically.
one of the easy way is using shortcuts like : Ctrl+F10, then press n "it show line number and hide line numbers.
The top answer is good but you can also bind it to a key ( shorcut ) to toggle it..
Window > Preferences > Keys then enter "Line Numbers" in filter and bind it to a key.
I use CTRL + S + L.
Open Eclipse
goto -> Windows -> Preferences -> Editor -> Text Editors -> Show Line No
Tick the Show Line No checkbox
click on window tab and click on preferences
do this and check show line number
the eclipse changes the perferences's position
to eclipse -> perferences
On a Mac do this:
cmd + , or ADT -> Preferences
Expand General -> Editors ->Text Editors
Check box: Show line numbers
Eclipse has a search feature in the top left box of the Preferences.
Type in 'line numbers' in that search box, and presto...
In case you're tired of googling each time you forget...
this will be the appropriate solution for asked question:
String lineNumbers =
AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER;
EditorsUI.getPreferenceStore().setValue(lineNumbers, true);