如何在Eclipse文本编辑器中获取格式的语法高亮?

问题描述:

在Eclipse文本编辑器中,我需要具有特定结构的文本的语法高亮。这个方案很简单基本上每行都有六个字被白空间分开,以#开头的行是注释。最重要的是突出意见,但是对于未评论的行中的六个要素进行单独着色将是有用的。

I need syntax highlighting for text with a specific structure in an Eclipse text editor. The scheme is simple; basically each line has six words separated by white-space, and lines starting with # are comments. Most important is to highlight the comments, but it would be useful to individually color the six elements in the non-commented lines.

如果太难以获得,我可以使用一个现有的插件,意味着类似语法的东西。任何建议?

If it is too complicated to obtain, perhaps I could use an existing plugin meant for something with a similar syntax. Any suggestions?

如果您想编写自己的编辑器,可以尝试 XText 。使用XText,您可以为自己的DSL(域特定语言)编写编辑器,我怀疑是您拥有的。编辑也支持自动完成和其他不错的功能。我迄今没有尝试过XText,但我听说这很容易学习。

If you want to write your own editor, you could try XText. With XText you can write editors for your own DSL (Domain Specific Language), which i suspect is what you have. The editors also support auto completion and other nice features. I haven't tried XText so far, but i heard that it's pretty easy to learn.

如果高亮显示评论就足够了,还可以尝试分配文件结束像属性文件的配置,属性文件中的sincec注释也是#。您可以在窗口 - >首选项 - >编辑器 - >文件关联中编辑配置,然后为文件类型选择属性文件编辑器。

If highlighting of the comments is enough, you can also try to assign your file endings like the configuration for properties files, sincec comments in properties files are also a #. You can edit the configuration in Window -> Preferences -> Editors -> File Associations and then choose the Properties File Editor for your file type.