Changing YAML Highlighting
-
Hi,
a project I am contributing to uses YAML style files, but has some additional syntax and changed the indentation style (tabs instead of 4xspaces). So it’s yaml but not really yaml. Which messes up the highlighting in np++.-
Now, I tried to reproduce YAML syntax highlighting with notepad++s UDL, planning to then make the changes I need. After trying this for some time I’m asking myself if that is even possible or is YAML highlighting a special case and hardcoded into np++?
-
Is there a way to export the existing highlighting rules for yaml from np++ to UDL?
Alternatively: Do you know a source for xml highlighting rules for YAML which I then could use in langs.model.xml? -
langs.model.xml has a line tabSettings=“132” at the yaml definition which appears nowhere else. If I knew what to replace 132 with to get tabs instead of 4xSpace would also be very helpful as a workaround.
-
If above are not possible how do I at least transfer the YAML highlighting from “default” to “bespin” styles?
Thank you very much for your help!
-
-
- … if that is even possible or is YAML highlighting a special case and hardcoded into np++?
Technically all highlighting is “hardcoded” into N++ because they are written in C++. N++ does not contain any UDLs by default. I don’t use UDL often enough to know if creating a YAML-like language is possible.
- Is there a way to export the existing highlighting rules for yaml from np++ to UDL?
No. The existing highlighting and UDLs work completely differently.
- langs.model.xml has a line tabSettings=“132”
In hex this value is
0x84
which is a combination of0x80
(which is a flag to indicate the use of spaces) and0x02
which is the number of spaces to use. For example if you wanted to use a tab with a width of 4 you’d use a value of0x04
which is to no surprise4
in decimal.- If above are not possible how do I at least transfer the YAML highlighting from “default” to “bespin” styles?
You would have to add that information to the bespin.xml theme file. The default style looks like this (below), so you’d have to modify the colors manually and add it to the file.
<LexerType name="yaml" desc="YAML" ext=""> <WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="IDENTIFIER" styleID="2" fgColor="000080" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" /> <WordsStyle name="COMMENT" styleID="1" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="INSTRUCTION WORD" styleID="3" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="instre1" /> <WordsStyle name="NUMBER" styleID="4" fgColor="FF8040" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="REFERENCE" styleID="5" fgColor="804000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="DOCUMENT" styleID="6" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="TEXT" styleID="7" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" /> <WordsStyle name="ERROR" styleID="8" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> </LexerType>
-
Thank you for your elaborate answer, however my problem remains.
tabSetting seems to influnce the width of a tabulator. It does not switch between spaces and tabs as relevant for the syntax of the language, just the appearance. So that doesn’t help.
I have no idea where that bespin.xml is saved, so I can’t manipulate it. Certainly not in the np++ folder or in MyDocuments. The bespin theme is also not metioned in any of the other xml files, no leads given…
Edit: I have found Bespin.xml on npp github, but the location I need to put it into doesn’t exist on my machine…I think what I want is just out of scope for np++. Great editor nonetheless.