Community
    • Login

    Issues with Syntax Highlighting for a Custom Language - Emmanuel Katto

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 281 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Emmanuel KattoE
      Emmanuel Katto
      last edited by

      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

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Emmanuel Katto
        last edited by

        @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:
        c70ea7be-99e4-4340-a3ae-03a09c119e9a-image.png

        …then add Styler settings and word2 to the 2nd group, and it takes effect immediately:
        7a2b8c5b-269c-4636-aaad-34bd84dc8389-image.png

        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.

        1 Reply Last reply Reply Quote 2
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors