• Login
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.0k 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.
  • D
    Dillon Ethier
    last edited by Jun 30, 2018, 5:02 PM

    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.

    C 1 Reply Last reply Jun 30, 2018, 8:54 PM Reply Quote 0
    • M
      Mikhail V
      last edited by Jun 30, 2018, 7:11 PM

      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
      • C
        Claudia Frank @Dillon Ethier
        last edited by Jun 30, 2018, 8:54 PM

        @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
        • M
          Mikhail V
          last edited by Jun 30, 2018, 11:01 PM

          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
          • D
            Dillon Ethier
            last edited by Jul 1, 2018, 4:33 PM

            Thank you very much! This is an adequate solution.

            1 Reply Last reply Reply Quote 0
            • P PeterJones referenced this topic on Feb 21, 2022, 9:19 PM
            3 out of 5
            • First post
              3/5
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors