Search code examples
eclipseeclipse-pluginsyntax-highlightingtext-editorfile-association

How can I get syntax highlighting for my format in an Eclipse text editor?


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?


Solution

  • 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.

    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.