Community
    • Login

    How can I style just the number prefix?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 533 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.
    • Peter LindP
      Peter Lind
      last edited by

      Hello

      I’m trying to style the number prefix in this language definition. It doesn’t seem to work, and I can’t seem to find other styles that has this.

      What I want is the prefix for numbers to be in a different style than the number. Like:

      #05

      I want the # to be in one style, and the 05 to be in another.

      Any way to do this?

      Thanks in advance!
      Peternpp style.PNG

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Peter Lind
        last edited by

        @Peter-Lind said in How can I style just the number prefix?:

        Any way to do this?

        In just native UDL? No.

        With the EnhanceAnyLexer plugin, you could define a regex that would be used to change the foreground color of matched text. For example, if you want #$ #% # $ % as prefixes to numbers to be a different color than the rest of the number, you could use Plugins > EnhanceAnyLexer > Enhance current language, then use

        0x0000FF = (?-s)(#\$|#%|#|\$|%)(?=[0-9a-f])
        

        You also either need to make sure that 3 isn’t in the list of excluded_styles in that config, or use the newer syntax (described in the ini file) which allows specifying a regex only for the specific style #3.

        This will turn the #$ #% # $ % prefixes red, even though the rest of the number is pink; and if those sequences aren’t before a valid number, then it won’t be highlighted either:
        44c85d51-350a-45c0-a851-e3b1773087a6-image.png

        Peter LindP 1 Reply Last reply Reply Quote 1
        • Peter LindP
          Peter Lind @PeterJones
          last edited by

          @ PeterJones Thank you!

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