问题
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?
回答1:
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.
回答2:
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:
* It ignores words inside comments tag.
来源:https://stackoverflow.com/questions/15415469/javascript-syntax-highlighting-in-eclipse-not-working