Issues with Syntax Highlighting for a Custom Language - Emmanuel Katto
-
Hello everyone,
My name is Emmanuel Katto. I’m trying to set up syntax highlighting for a custom programming language in Notepad++, but I’m running into some challenges. Here are the details:
I’ve created a user-defined language (UDL) but it doesn’t seem to highlight keywords and functions correctly. What are the common pitfalls when defining a new language?
I’m not sure how to properly categorize keywords, functions, and comments. Can anyone provide examples of how to structure these in the UDL settings?
After making changes to the UDL, I’ve noticed that sometimes they don’t appear to take effect immediately. Is there a way to refresh or reload the UDL without restarting Notepad++?
Please help…
Thanks,
Emmanuel Katto -
I’ve created a user-defined language (UDL) but it doesn’t seem to highlight keywords and functions correctly
It does for me. Could you be a bit more specific?
I’m not sure how to properly categorize keywords, functions, and comments.
Put your various keywords in the different Keywords fields; if you have different groups of keywords that you want styled differently, put them in different fields, otherwise you can just put all the keywords together.
For UDL, “Functions” are just a kind of keyword, from the perspective of a UDL (or any of the builtin syntax highlighters). Unless you are talking about the Function List panel in Notepad++, in which case you need to set up the FunctionList definition as described in the User Manual > Config Files > Function List Definitions. Our Function List Basics FAQ is a great starting point for understanding the structure of the Function List definition. However, getting the regex right for classes and functions can be a bit tricky… it’s usually best to start at the simplest, and slowly increase the complexity of the regex with frequent testing. (And Function List definitions are annoying, in that you have to restart Notepad++ with every change you make, no way around it.)
UDL Comments are a separate concept from keywords, and I am not sure why you are trying to “categorize” comments alongside keywords. You just set up the Comment Line Style and/or Comment Style, and then the comments are styled separately (and, unless you enable the checkmarks in those Styler boxes, there won’t be any keywords or other syntax highlighting inside a comment)
After making changes to the UDL, I’ve noticed that sometimes they don’t appear to take effect immediately
They do take effect immediately. Not sure why it seems to you that they don’t.
Start with:
…then add Styler settings and
word2
to the 2nd group, and it takes effect immediately:
But because your complaints were rather vague, I can just give overview-style help. “More details” is “more better” when asking for this kind of help.