Community
    • Login

    Syntax Highlightning for folder path in custom language

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 248 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.
    • Mad RheezaM
      Mad Rheeza
      last edited by

      Hey, i am new in npp and need your help, how can i highlight full folder path in custom language?
      I added " C:\ C:/ E:\ E:/ D:\ D:/ " in keywords lists, and it works only if path without spaces like
      C:\Users\Mad\TextOne.txt
      if i am using path
      C:\Users\Mad\Text Two.txt
      its highlight only C:\Users\Mad\Text

      e32b2cd8-e957-4b8d-b469-873411127ad3-image.png

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Mad Rheeza
        last edited by

        @Mad-Rheeza ,

        The User Defined Lanauge (UDL) system is not that powerful on its own.

        If you use the EnhanceAnyLexer plugin, you can use a regular expression to define it.

        But good luck in coming up with a regex that can distinguish between two similar (or identical) sets of text which mean two different things:

        I want to rename c:\path\filename as blah.txt
        I want to rename c:\path\filename as blah.txt
        

        In the first instance, it’s really implying “I want to rename c:\path\filename as blah.txt” to mean a single filename with spaces. The second is really implying “I want to rename c:\path\filename as blah.txt”

        And by “good luck”, I meant, “that’s an impossible task, without caveats”.

        If you have the caveat of “each line that starts with a drive letter then a colon then forward-or-backward-slash is a single filename, which may or may not include spaces, all the way to the end of the line”, then it’s easy. Something like ^[A-Z]:[\\/].*?$ will handle that.

        Or if you defined that all filenames with spaces must have double-quotes around (like the cmd.exe prompt and Windows > Run dialog require), then it’s also not too bad: Something like [A-Z]:[/\\]\S+|"[A-Z]:[/\\].+?" might work (the left half of the alternation before the | is for filenames without spaces, and the right half is for filenames in quotes, which might contain spaces.

        Or if you always have a three-letter extension, then [A-Z]:[/\\].*\.[A-Za-z]{3} would likely work.

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