Distinguishing single line and multi-line comments
-
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.
-
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.
-
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 -
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.
-
Thank you very much! This is an adequate solution.
-