Change Eclipse variable autohighlight color - eclipse

I have customized my own colors in eclipse but cannot find where to change the auto highlight color when you click on a variable and it highlights all other uses. Has anyone done this before?

Preferences -> General -> Editors -> Text Editors -> Annotations -> Occurrences

How to change your various variable background-highlighting "occurrences" settings
For anyone who'd like a screenshot and more details:
Tested in Eclipse 2022-12 (4.26.0) on Ubuntu 22.04.
You may have various "Occurrences" settings to change. Each one causes variables of the same name from various language file types to be highlighted in different kinds of files. I have 5 or so "occurrences" settings in Window → Preferences → General → Editors → Text Editors → Annotations → in the “Annotation types” window:
Bash occurrences
C/C++ Occurrences
C/C++ Write Occurrences
Occurrences
Occurrences (LiClipse)
I have changed all 5 to the same custom color: #414104, which is a nice-looking brown which looks great for dark themes.
Here's a screenshot prior to changing that setting for "Occurrences (LiClipse)":
And here's the new color I set all 5 to: #414104:
References:
The accepted answer
I first wrote about this in my Eclipse setup instructions on a new Linux (or other OS) computer document, where I have documented this and a lot more.

Related

Find all assignments to variable

Eclipse has an easy way to find all references to a variable, but is there a quick way to only look for assignments?
Quick? Hm... Find all references with Ctrl+Shift+G, then filter in the Search view (results) via the View menu (dropdown triangle). You can select Reads there to filter these.
Shortcut: Cursor to the variable, menu Search > Write Access > Workspace. No keybinding assigned by default, but you can do this as usual (Preferences > General > Keys).
Ctrl+Shift+U shows all usages of a variable, with different icons for read and write references.
You can also set different colors for read and write occurrences of the selected variable (in the right part of the editor). These colors are set in Eclipse preferences, in "General -> Editors -> Text editors -> Annotations". There is "Occurences" and "Write occurences". I set the same color, slightly darker for "Write occurence", so I can easily spot write occurences, without any key stroke.
Ctrl+Alt+U finds all the references within a class (local references) for a particular variable, on my ubuntu machine.

Where to change highlight color for selected occurrences in Eclipse?

When a method or variable is selected it is highlighted in Eclipse with some color. Can anyone advice where to change that color? I'm working under Windows OS.
I've found where to change it:
Preferences -> General -> Editors -> Text Editors -> Annotations
and there you have to change both "Occurrences" and "Write occurrences".
Preferences -> General -> Editors -> Text Editors
Current Line Highlight
I think you want the above
else
Preferences -> Java -> Editor -> Syntax Coloring
Element -> Java -> Method or Variable
Check Enable and select color
This has made me mad for about half an hour.
If the issue appears in JavaScript files, the option is under Preferences -> General -> Editors -> Text Editors -> Annotations and in the Annotation types choose JavaScript Occurences. Mine was set to black, nasty little thing took me too long to fix.
If you're using eclipse with PHP package and want to change highlighted colour then there is slight difference to above answer.
Right click on highlighted word
Select 'Preferences'
Go to General > Editors > Text Editors > Annotations. Now look for "PHP elements 'read' occurrences" and "PHP elements 'write' occurrences". You can select your desired colour there.

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)

How can I show line numbers in Eclipse?

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

how to hide the text limit line in netbeans 6.5?

Is there a way to hide the text limit line in netbeans 6.5?
In NetBeans 6.9, setting Right Margin to 0 effectively hides the text limit line.
Set the value in Preferences > Editor > Formatting > All Languages > Right Margin.
(Mac OS X 10.6.4, NetBeans 6.9)
line is not moving to 200 column, but you can hide it setting its color to same as the background
You can set it to 0. So It will not be visible.
Are you talking about the line running thru the right side, by default at the 80 column point? That is Options -> Editor -> Indentation -> Right margin. I have it set at 200 columns which pushes it off the right side of the screen.
Hi~ I found out how to hide "Text limit line" :)
Tools -> Options -> Export(Popup Win) -> Browse.. (Select target "ccc.zip" file)
Select Options for Export : Check at "Editor" -> OK
Edit xml file "\Editors\Preferences\org-netbeans-modules-editor-settings-CustomPreferences.xml" in "ccc.zip" file.
<entry javaType="java.lang.Boolean" name="text-limit-line-visible" xml:space="preserve">
<value><![CDATA[false]]></value></entry>
Tools -> Options -> Import "ccc.zip" file
Done
As for now (October '18) in NetBeans 8.2 + 9 you can hide the text limit line or actually change its color by going to Options -> Fonts & Colors -> Highlighting -> Text Limit Line -> Foreground
Remember to go to tools, options, fonts & colors, highlighting tab, text limit line selected before exporting ccp.zip....
There is an easy way to disable the warning generated by NetBeans for number of lines.
Goto Tools > Options > Editor > Hints
Find the checkbox Too Many Lines > un-check the checkbox
and click Apply.
Enjoy :)
Have you tried to see if your project properties have formatting that overwrites the global properties?
See below:
https://bz.apache.org/netbeans/show_bug.cgi?id=223329