Community
    • Login

    Distinguishing single line and multi-line comments

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    comment lineuser-definedcomment stylecommentscomment block
    5 Posts 3 Posters 2.7k Views 2 Watching
    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.
    • Dillon EthierD Offline
      Dillon Ethier
      last edited by

      I’m trying to set up UDL for Julia and I’m running into an issue with multi-line comments. The problem is that in Julia, single-line comments are delimited with a #, but multi-line comments are delimited with #= and =#, so whenever N++ sees a multi-line comment it just sees the # and assumes it’s a single-line comment and won’t highlight the remaining lines. Is there a way to get it to distinguish between the two types of comments? If I could use regex this would be easy, but apparently UDL does not support that at this time.

      Claudia FrankC 1 Reply Last reply Reply Quote 0
      • Mikhail VM Offline
        Mikhail V
        last edited by

        Unfortunately there are limitations in UDL. So with this one you are out of luck.
        I know one workaround for this.

        So to make colors work: in UDL you leave both “Comment line style” and “comment style” boxes empty.
        Then go to “operators and delimiters” tab and first define multiline comment delimiters,
        Open: #= Close: =#.
        Then (it must be defined after multiline delimiters) you define single line comment:
        Open: # Close: ((EOL))

        Now the colors should work.

        After that you’ll need commands to comment/uncomment selections.
        This can be done via Pythonscript plugin.
        Actually it might be done just with Regex replace but I prefer scripting solution.
        By scripting the idea is to define small scripts that work on selected text and insert # or #= where needed. If you know Python this should be easy to do.

        With Regex only this should work also but I am no expert in Regex.

        1 Reply Last reply Reply Quote 3
        • Claudia FrankC Offline
          Claudia Frank @Dillon Ethier
          last edited by

          @Dillon-Ethier

          in addition to what @Mikhail-V said you can use a combination of comments and delimiters like defining the multi-line comment as usual, with #= and =# and the line comment as suggested as an delimiter with open # and close ((EOL))

          Cheers
          Claudia

          1 Reply Last reply Reply Quote 3
          • Mikhail VM Offline
            Mikhail V
            last edited by

            Indeed, @Claudia-Frank is right here - for this case it is better only to define line-comment by delimiters, and multi-line leave in the comments definition. This way only line comment will need a new command.

            1 Reply Last reply Reply Quote 0
            • Dillon EthierD Offline
              Dillon Ethier
              last edited by

              Thank you very much! This is an adequate solution.

              1 Reply Last reply Reply Quote 0
              • PeterJonesP PeterJones referenced this topic on

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors