Style words depending the end character
Hi, I have a question about user defined language. I would like to mark Words from the end to the begining.
For example anthing before “:” I would like to give an special style. (until the begining of line)
I can define always in fordward direction, But I tried many times this…and never find the solution.
But I tried many times this…and never find the solution.
That’s because the User Defined Language (UDL) definition just has a simple set of rules that it can make use of, and fancy rules that you described are not possible with UDL alone.
However, using the EnhanceAnyLexer plugin, you can add a regex-based rule in addition to the normal UDL-based highlighting:
- Install EnhanceAnyLexer ((use Plugins > Plugins Admin to install that plugin)
- Open a file that’s using your UDL
- Plugins > EnhanceAnyLexer > Enhance Current Language, which will open
EnhanceAnyLexerConfig.iniand create a section in the INI file that matches the name of your lexer. (Example: if your UDL were called “TxoteLanguage”, then the section in the INI would be
- To change the foreground color for anything before a
:on a line, you define a regex which matches from the beginning of the line up-to-the-
:… For example, to make it red:
If you don’t want the
[TxoteLanguage] 0x000000FF = ^.*?:
:to be red, but just the text before it, use a fancier regex, which requires a colon after but doesn’t include the colon in the match:
[TxoteLanguage] 0x000000FF = ^.*?(?=:)
The INI file includes comments which explain how to set the colors (
defined language enhancedanylexer local variables
It is posible to create a regex espresion ,save the results, and use it for a new search? let me explain. I would like to color the local variables on CNC programs. like this.
DEF REAL DIAM
local variables have to be defined at the beginig of the program by DEF REAL/INT/… SOMETHING
I can search for the words declared as local by:
But this one only mark DIAM. I will like to use the match DIAM to be the next search…
Sorry, the EnhancedAnyLexer plugin doesn’t work that way. It cannot take the matching word from a pattern on one line, and highlight that same text even in different circumstances later.
You seem to want more features than UDL alone, or UDL-plus-EnhanceAnyLexer, can give you. At that point, the remaining option is to write a custom lexer for your language: but that’s a complicated task, and we’re not going to do that for you; you will either have to write your own lexer, or hire someone to do it for you. (And no, there’s no “request for hire” section in this forum; if someone is interested, they could private-message you using the chat feature in the forum, but this isn’t a “jobs board”.)
[Also, you originally posted your second message as a separate Topic, but since it was about syntax highlighting in the same UDL, I merged it together, so that people can get the full conversation without having to click links to other discussions.]