Custom syntax highlighting

Is there a way to provide highlighting (custom colors) for certain patterns?

For example, I might want to a special highlight for {{stuff}} templates, or for _("string") . It should be fairly straightforward but I don't see any option or plugin... Please help.

Comment actions Permalink

I think it's worth a feature request for custom highlighting based on regex.
Please submit one:

Comment actions Permalink

Hi there,

Nope. It has to be coded via plugin so IDE is aware of such stuff.

IDE splits file content into AST (runs through lexer / parser) .. so just highlighting some random chuck of text (that just matches some pattern) is not a straightforward task.

 Related tickets (these and those mentioned in "Relates to" list):

{{stuff}} -- this is definitely looks like a new template language ... so it has to be done via plugin (if you want to add it on top of existing syntax/already recognized content in current file).

Comment actions Permalink

At the same time, PHPStorm (and the rest of the family) has the ability to customize the "TODO" words with a regex, so this should work the same.

I'm surprised such a plugin does not exist already. Or does it?

Comment actions Permalink

I'm not aware of such plugin.

Considered that you are not the first who asks this kind of question (custom highlighting of some text fragment .. or how to tell IDE that my custom template syntax is a valid one) ... I do not think it does exist.

Lets see what JB support team will tell you -- they should know their product better than me.

Comment actions Permalink

Andriy is right - template language and a TODO comment pattern are two whole different worlds.

What is that {{stuff}} and _("string") template language that you want to use?

Comment actions Permalink

I'm currently converting an existing javascript and PHP app for localization, and I want a quick way to differentiate between "normal" strings and translatable ones.

In PHP, _() is an alias of gettext() function, so it signifies text that's going through the translation via gettext. In javascript I'm using "{{}}" style messages with a gulp plugin and a js lib to translate html and js.

But the possibilities are endless. You may refactor a project and want to highlight obsolete constructs - suppose you want to convert a javascript project from Promise.then() style to async/await. A custom highlighting solution would allow you to simultaneously highlight "old-style" code and "new-style".


Please sign in to leave a comment.