User Defined Language
-
Hello, I am currently trying to make my User Defined Language highlight some words depending on the context using delimiters but one of my delimiters ended up overlapping the other. I wanted to make different styles based on the parenthesis, like () and [] is one style and (] and [) is another style. The words in these (), [], [) and (] would also turned into that color based on the parenthesis. Therefore, I could not get the result I wanted. Is there a way to get what I am trying to achieve?
What I am trying to achieve:
[words] or (words) => would be in orange color

(words] or [words) => would be in green color

But the result i got was(words] or [words] ended up being orange color
[words] and (words) were not affected

-
With just the User Defined Language (UDL) syntax, what you want is probably not achievable.
However, if you install the EnhanceAnyLexer plugin (using Plugins > Admin tool), then you can make sure your file has the right UDL active, then use Plugins > EnhanceAnyLexer > Enhance Current Language to edit the plugin’s config file. You can then define foreground color changes using “0xBBGGRR = regex” pairs.

[udf] ; color each word, 0x66ad1 is the color used, see the description above for more information on the color coding. 0x0080FF = \([^)\\]]*?\) 0x0080FF = \\[[^)\\]]*?\\] 0x00FF80 = \([^)\\]]*?\\] 0x00FF80 = \\[[^)\\]]*?\) ; check in the respective styler xml if the following IDs are valid excluded_styles = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20,21,22,23In my example, I defined four regular expressions: two will match the balanced `` and
(...); the other two match the imbalanced[...)and(...]If you don’t want it to match multiline, change each of those four regex to have
\r\nright after the^, so that it doesn’t look for parenthesized text that spans across newline characters.note: mine used
[udf]as the header, because I was in an unnamed UDL. If you follow my instructions above, yours will have[YourUdlNameHere]instead.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login