I would like to define a language (or script) once and then have it activated automatically when I select the matching language, to avoid highlighting files that are not needed but also avoiding having to paste the script each time.
That’s the way it works.
why does it change the text font?
It doesn’t. EnhanceAnyLexer only changes foreground color.
I once reopened the ini and, yes, it contained my additions, but it had also restored things I had deleted
I’ve never seen that happen.
on one occasion the file I was trying to highlight came up as modified.
EnhanceAnyLexer just changes colors; it does nothing with the text / contents in the highlighted file, so it does not edit the file. The plugin would not cause a file to “come up as modified”.
how and when you apply the script what do you mean by NameOfUDL? can I associate the highlighting I define with a language?
EnhanceAnyLexer works by hooking in to the activated lexer language, whether it’s one of the built-in languages, or one of the UserDefinedLanguages (UDL).
So to make it work:
Define a UDL for your language. You will give it a name: my example was NameOfUDL. Set the Language of the current file to NameOfUDL under normal circumstances, you could make Notepad++ do it automatically, based on file’s extension, in the UDL definition but you’ve indicated you want to turn this on or off at will (or to change it between one of three languages), instead of having it automatic based on extension EnhanceAnyLexer > Enhance Current Language this will allow you to set up the color / regex mappings for NameOfUDL while you are initially setting them up, you might see some weird things, like sometimes highlighting and sometimes not; it behaves differently while you’re actively editing EnhanceAnyLexer.ini than it does when you’re just using it you have to save it once you are done, otherwise your changes to EnhanceAnyLexer.ini will be lost; it’s a file, just like any other you only have to do this step once per Language once it’s saved, you can close the EnhanceAnyLexer.ini . If not all the enhancements show up in the active file, and it’s got NameOfUDL as the active language, you may have to switch to a different tab and back, or close and re-open the file to get EnhanceAnyLexer to take control.So, if you have three separate languages that you’ll want to apply for your use-case, you will need to create three different UDLs (User Defined Languages) – I’ll call them NameOfUDL1, NameOfUDL2, and NameOfUDL3. Then you will have to Enhance Current Language once for each of those (or do it once, and copy/paste into three different sections in EnhanceAnyLexer.ini, making sure to have the correct name of each section. Then the next time you activate one of NameOfUDL1, NameOfUDL2, or NameOfUDL3 for a given file, it will apply the enhancements defined for the chosen UDL.
Here’s an example:
file:
T1| otherstrings something but not T1| otherstrings hereExcerpt from Languages menu:
30bc249b-ffcb-431a-89b4-0a2ece7025b9-image.png
Excerpt from EnhanceAnyLexer.ini:
[nameofudl1] # 0x0000FF = ^T\d(?=\|) 0x00CC00 = ^T\d\K\| [nameofudl2] # 0xC0C000 = ^T\d(?=\|) 0x00CC00 = ^T\d\K\| [nameofudl3] # 0xFF00FF = ^T\d(?=\|) 0x00CC00 = ^T\d\K\|For this simple example, they are highlighting the same regex, but with different colors, just so you can see it is applied. All I had to do to change which EnhanceAnyLexer config was active was change the selection in the Language menu.
Here are screenshots with four different Language menu entries selected:
Selected Language Screenshot Normal Text 6eb6571f-6b89-4703-bb01-c07b38a5c7d1-image.png NameOfUDL1 44d2548f-3e8d-4e87-83b8-519feb8e8298-image.png NameOfUDL2 1cb8c5e2-9de5-4204-8962-20090a30c492-image.png NameOfUDL3 f3d9c7ef-f4ac-4fba-a67c-6f0b2ee3e404-image.png