17

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?

2
  • 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. Mar 14, 2013 at 16:55

4 Answers 4

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.

4
  • 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 5, 2014 at 2:04
  • 12
    I don't see a "Javascript editor" in editors. Mar 20, 2021 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. Apr 28, 2021 at 19:41
  • I'm using Eclipse 2023-12. Under "Internal editors", "javascript editor" does not exist.
    – lurker
    Feb 24 at 1:09
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

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

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.

1
  • 2
    This doesn't appear to work in Eclipse 2020-09 out of the box.
    – thdoan
    Oct 8, 2020 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.