简体   繁体   English

Eclipse 中的 Javascript 语法高亮显示不起作用?

[英]Javascript syntax highlighting in Eclipse not working?

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.我想为我正在使用的某些 Javascript 代码突出显示语法,因此我通过 Eclipse 安装了“Web 开发人员工具”和“Javascript 开发人员工具”。 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 .我做了一些搜索,似乎对于不是作为 Javascript 项目创建的项目,语法突出显示不起作用

Actually, I am not sure how to implement the solution on that webpage, I'm not really sure what "vim" is.实际上,我不确定如何在该网页上实施解决方案,我不确定“vim”是什么。 (I don't think it's the text editor) (我不认为这是文本编辑器)

Is there an alternate way to get this syntax highlighting working?有没有其他方法可以让这种语法高亮显示工作?

Check your "File Associations" setting to ensure that *.js files are associated with the JavaScript Editor by default.检查您的“文件关联”设置以确保 *.js 文件默认与 JavaScript 编辑器相关联。

  • Window > Preferences窗口 > 首选项
  • General > Editors > File Associations常规 > 编辑器 > 文件关联
  • Under "File types" select "*.js"在“文件类型”下选择“*.js”
  • If not present, under "Associated editors" click on "Add..." and choose Internal > JavaScript Editor如果不存在,在“Associated editors”下点击“Add...”并选择Internal > JavaScript Editor
  • Under "Associated editors" click on "JavaScript Editor" and select the "Default" button在“Associated editors”下点击“JavaScript Editor”并选择“Default”按钮

If you are developing in the JavaScript perspective, this should already be set.如果您是从 JavaScript 的角度进行开发,则应该已经设置了它。 It's possible that you are developing in a different perspective that does not have this association preset.您可能正在以没有此关联预设的不同视角进行开发。

File association is definitely a place to check.文件关联绝对是一个检查的地方。 In the 2021-03 build, the Generic Text Editor actually has js highlighting.在 2021-03 版本中,通用文本编辑器实际上具有 js 突出显示。 The previous default for me was Text Editor.我以前的默认设置是文本编辑器。 When I switched to Generic Text Editor, it works当我切换到通用文本编辑器时,它可以工作在此处输入图片说明

In the new Eclipse Oxygen build, the word recurrences highlighter works natively, no need for special plugin.在新的Eclipse Oxygen版本中,重复荧光笔这个词本身就可以工作,不需要特殊的插件。 It works in XML/HTML/JS Editors - just double click on a word, and see (*almost) all recurrences highlighted:它适用于XML/HTML/JS编辑器 - 只需双击一个单词,即可查看(*几乎)所有突出显示的重复项:

在此处输入图片说明

* It ignores words inside comments tag. * 它忽略注释标签内的单词。

"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). “Web 开发人员工具”实际上不起作用:它看起来像一个错误,因为无论我尝试过的“首选项”中的任何修改,javascript 文件中都没有语法高亮显示)。

(And "Javascript Developer Tools" doesn't exist anymore) (并且“Javascript 开发人员工具”不再存在)

You need to install "Wild Web Developer" ("Help" > "Install new software" and search for "Wild Web Developer").您需要安装“Wild Web Developer” (“帮助”>“安装新软件”并搜索“Wild Web Developer”)。

After installed, restart and it will work out of the box (no need to fiddle inside 'Preferences')安装后,重新启动,它将开箱即用(无需在“首选项”中摆弄)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM