16

I would like syntax highlighting for some Javascript code that I am working with, so I installed "Web Developer Tools" and "Javascript Developer Tools" through Eclipse. I checked the preferences to make sure the syntax highlighting was enabled but it doesn't seem to be working.

I did some searching and it seems that for projects that are not created as Javascript projects, the syntax highlighting doesn't work.

Actually, I am not sure how to implement the solution on that webpage, I'm not really sure what "vim" is. (I don't think it's the text editor)

Is there an alternate way to get this syntax highlighting working?

Fam
  • 580
  • 1
  • 7
  • 29
  • Is the syntax highlighting dependent upon your file extension? Could you save the file as a .js and see if that enables it? Notepad++ enables syntax highlight for JavaScript when I am working with .js files. – Anthony Forloney Mar 14 '13 at 16:55
  • http://stackoverflow.com/questions/2375122/javascript-syntax-check-in-eclipse – topcat3 Mar 14 '13 at 16:59

4 Answers4

9

Check your "File Associations" setting to ensure that *.js files are associated with the JavaScript Editor by default.

  • Window > Preferences
  • General > Editors > File Associations
  • Under "File types" select "*.js"
  • If not present, under "Associated editors" click on "Add..." and choose Internal > JavaScript Editor
  • Under "Associated editors" click on "JavaScript Editor" and select the "Default" button

If you are developing in the JavaScript perspective, this should already be set. It's possible that you are developing in a different perspective that does not have this association preset.

Rick Viscomi
  • 8,180
  • 4
  • 35
  • 50
  • 1
    It should be noted, if it was already opened in normal eclipse editor, you need to close and reopen file for that to take effect. (The JS editor as default should be set automatically.) – NoBugs Jan 05 '14 at 02:04
  • 11
    I don't see a "Javascript editor" in editors. – Durga Swaroop Mar 20 '21 at 17:40
  • Seems to be "JS Editor", trying to associate *.js with that by selecting both the file extension that "JS Editor" and press apply. No success. Restarting eclipse without getting syntax highlighting. – Anders Lindén Apr 28 '21 at 19:41
5

File association is definitely a place to check. In the 2021-03 build, the Generic Text Editor actually has js highlighting. The previous default for me was Text Editor. When I switched to Generic Text Editor, it worksenter image description here

tuotuoZ
  • 69
  • 1
  • 2
2

"Web Developer Tools" doesn't work in fact: It looks like a bug since there's no syntax highlight in javascript file whatever modification in "Preferences" I've tried).

(And "Javascript Developer Tools" doesn't exist anymore)

You need to install "Wild Web Developer" ("Help" > "Install new software" and search for "Wild Web Developer").

After installed, restart and it will work out of the box (no need to fiddle inside 'Preferences')

ThePhi
  • 2,373
  • 3
  • 28
  • 38
0

In the new Eclipse Oxygen build, the word recurrences highlighter works natively, no need for special plugin. It works in XML/HTML/JS Editors - just double click on a word, and see (*almost) all recurrences highlighted:

enter image description here

* It ignores words inside comments tag.

Noam Manos
  • 15,216
  • 3
  • 86
  • 85