score:486

Accepted answer

try:

window > preferences > java > editor > mark occurrences 

select all options available there.

also go to:

preferences > general > editors > text editors > annotations

compare the settings for 'occurrences' and 'write occurrences'

make sure that you don't have the 'text as higlighted' option checked for one of them.

this should fix it.

score:-1

sometimes problems in your project build path can cause this, make sure you resolve it first, in my case the prolem was :

enter image description here

and when fix it highlights come back.

score:-1

i had this issue with eclipse mars for php developers, 64 bit edition for windows. i now discovered that highlighting works out-of-the-box with the 32 bit version. even with a fresh download of the equivalent 64 bit build, highlighting does not work. so i will switch back to 32 bit (this is actually not the first problem i observe with eclipse 64 bit).

edit:

i thought this was the solution, so i installed the 32 bit version in c:\program files (x86) and set a shortcut in the "start" menu. when i started eclipse from there, highlighting again ceased to work. i now got it working again by deleting the .metadata directory in the workspace (i.e. resetting the workspace settings) and re-importing the projects.

score:0

i was having the same issue and the "make occurrences" and "annotations" solutions above did not help. if you are using maven, i had to convert the project to a maven project (right click on it in the package explorer and go down to configure), then build the project. then the syntax coloring and highlighting worked correctly.

score:0

this is what worked for me (credit to yardenst from another thread): instead of double clicking file when opening, right click on file -> open with -> java editor

screenshot

score:0

in scala ide click on this button in the toolbox to activate mark occurrences (off by default).

link to the screenshot

score:1

maybe because it not supports code highlights inside scriplets. not sure though.

you can try using one of the eclipse plugin like 'glance search' which works great. here's a link for that- http://code.google.com/p/eclipse-glance/

score:1

i just unchecked all, applied, checked all again, applied and it worked :) hopefully helps others.

score:1

eclipse toolbar > windows > preferences > general (right side) > editors (right side) > text editors (right side) > annotations (right side)

for occurrences and write occurrences, make sure you do have the 'text as highlighted' option checked for all of them. see screenshot below:

enter image description here

enter image description here

enter image description here

score:2

for php you can set

window > preferences > php > editor > mark occurrences 

please check first checkbox (mark occurrences of selected element in the current file)


and also check

preferences > general > editors > text editors > annotations

'occurrences' and 'write occurrences' with different style and color

score:2

if highlighting is not working for large files, scalability mode has to be off. properties / (c/c++) / editor / scalability

score:2

java - editor - mark occurrences in eclipse photon.

java - editor - mark occurrences

eclipse java ee ide for web developers. version: photon release (4.8.0)

score:3

for others running into this without any of the above solutions working and you have modified the default theme, you might want to check the highlight color for occurrences.

preferences > general > editors > text editors > annotations

then select occurrences in the annotation types, and change the color box to something other than your background color in your editor. you can also change the highlight to a outline box by checking "text as" and selecting "box" from the drop-down box (which is easier to see various syntax colors then with the highlights)

score:3

i wish i could have read the response by @ján lazár.

in addition to all the configurations mentioned in the accepted answer, below setting solved my misery:

for large files the scalability mode must be turned off. enabling scalability mode will disable reference highlighting.

enter image description here

ps: @rob hruska it would be great if this point is added in the accepted answer. most of the readers do not bother to read the last response.

score:5

using alt + shift + o it works for me!

score:6

the only that worked for me was:

java > editor > mark occurrences:
check "mark occurrences of te selected element in the current file."
... and maybe all the ones below.

score:25

there is a bug in eclipse juno (and probably others) but i have a workaround!

if you have already checked all the configurations mentioned in the top answers here and it's still not working try this.

to confirm the problem:

  1. select a variable
  2. notice the highlight didn't work
  3. click away from eclipse so the editor loses focus.
  4. click on eclipse's title bar so it regains focus, your variable should be highlighted.

if this is happening for you, you must close all of your open files and reopen them. this bug seems to also make weird things happen with ctrl+s saving of an individual file. my guess is that something is happening whereby internally eclipse believes a certain file has focus but it actually doesn't, and the ui's state is rendered as though a different file is being edited.

edit: if it's still not working, you might need to restart eclipse, but if you don't want to, try selecting the item you want to see occurrences of then disable and re-enable the mark occurences toggle button.

which looks like this

score:50

alt + shift + o
will solve your problem and agree with @korhan ozturk as well :)

this is known as toggle mark occurrence (alt + shift + o), means will highlight all occurrence of focused variable. same thing can be achieved from tool bar as follows

enter image description here

in same tool bar there is another switch if you turn that on you will see complete path for opened file, that is breadcrumb enter image description here

there are some more very useful switches like word wrap, show white characters just after toggle mark occurrence


Related Query

More Query from same tag