I have a custom syntax in a text file. I need to scan the file for certain strings with regular expressions.
I used Tools - Syntax Editor to create and save a new syntax file.
I defined a new Keyword group and a new keyword like this: \d\d.\d\d.\d\d\d\d (to find the date).
I go to Environment - Themes - Customize - Syntax highlighting - Highlighters, select my file, find my defined keyword group and give it a distinctive format.
To test it, I write some date, eg.: 14.10.2024, and select my custom syntax highlighter from the combo box.
Nothing happens, the date is not at all recognized. What is wrong?
Help defining a custom syntax file
Re: Help defining a custom syntax file
You need to escape dots, i.e. write \d\d\.\d\d\.\d\d\d\d -- or \d{2}\.\d{2}\.\d{4} (which is more readable, methinks).
I did some tests and I can see there is a bug in the code, though: the background for a (new) keyword isn't used if the keyword is on the last line. It works, if I add a newline after the line with a keyword.
Edit: it's not a bug, I just needed to move caret to another line (and I didn't )
I did some tests and I can see there is a bug in the code, though: the background for a (new) keyword isn't used if the keyword is on the last line. It works, if I add a newline after the line with a keyword.
Edit: it's not a bug, I just needed to move caret to another line (and I didn't )
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus
Re: Help defining a custom syntax file
Thanks for the reply, pjj.
I took your suggestion and defined my keyword as: \d{2}\.\d{2}\.\d{4} and saved the file.
The date's format is still not changed.
I made it purple and bold so that the difference can be clearly noticed.
I took your suggestion and defined my keyword as: \d{2}\.\d{2}\.\d{4} and saved the file.
The date's format is still not changed.
I made it purple and bold so that the difference can be clearly noticed.
Re: Help defining a custom syntax file
Can you post your .syx file here?
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus
Re: Help defining a custom syntax file
I've changed keyword group name from Data to #Data (i.e. put hash sign # before it) and it works for me.
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus
Re: Help defining a custom syntax file
Thanks pjj, starting a keyword group name with # works.
But why is this? Does the # tell RJ TextEd that what follows has to be interpreted as a regex instead of a literal string?
But why is this? Does the # tell RJ TextEd that what follows has to be interpreted as a regex instead of a literal string?
Re: Help defining a custom syntax file
I think so, yes.
Glad it works for you
Glad it works for you
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus
Re: Help defining a custom syntax file
Where is this documented? I could not find any info on this in the documentation.
If RJ TextEd has capabilities beyond what is documented, it is a great loss. The manual should be updated.
Especially with something so rare and useful like using regex to make a custom syntax highlighting file.
Not many text editors are capable of such a feat. I know only of CudaText and EmEditor.
If RJ TextEd has capabilities beyond what is documented, it is a great loss. The manual should be updated.
Especially with something so rare and useful like using regex to make a custom syntax highlighting file.
Not many text editors are capable of such a feat. I know only of CudaText and EmEditor.
Re: Help defining a custom syntax file
Turns out it is mentioned in the help file: TextEd > Syntax files > Keywords.
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus