Multiple styles of commenting?

Multiple styles of commenting?

2
NewbieNewbie
2

    Mar 16, 2005#1

    Is there a way to specify multiple styles of commenting?

    For example:

    Comment lines starting with two dashes are one color,
    Comment lines starting with two dashes and a pipe are another color.

    I tried playing around with the wordfile and looking in the help, but could not come up with an answer.

    Thanks in advance for any help

    6,683583
    Grand MasterGrand Master
    6,683583

      Mar 17, 2005#2

      Yes, it is possible in general with block and alternative block comments. If block comment off is not specified, the block comments act as additional line comments.

      But in your special case, this could be a problem, because comment 1 is also part of begin of comment 2. So it depends on the internal compare order of UltraEdit, if two dashes and pipe or only two dashes is found first. You will have to play with it to find out which comment definition has to be defined with two dashes only, so both comments are highlighted really as different comments.

      So try first
      Line Comment = -- Block Comment On Alt = --|
      and if it doesn't work try
      Line Comment = --| Block Comment On Alt = --

      Post the result of your test, because I'm also interested in the order which is necessary to get this to work.
      Best regards from an UC/UE/UES for Windows user from Austria

      2
      NewbieNewbie
      2

        Mar 29, 2005#3

        Thanks

        This is what works for multiple styles of commenting in this case.

        Line Comment = --| Block Comment On Alt = --

        3
        NewbieNewbie
        3

          Jan 23, 2007#4

          Hi... excuse me for dragging up an old thread... consequence of using search before blindly posting questions ;-)

          But in fact, this thread is exactly the question I had too and has to a large part already helped me.

          In my case its: Line Comment = --^ Block Comment On Alt = --

          But I'm still stuck with a small problem... I'd prefer -- to be my primary comment style. Or, in other words, when I select a block of code and choose "Comment Add" from the context menu, I want -- to be used and not --^

          So is there a way to use "alternative" comments for "Comment Add" or some other way to actually define my normal/alt comments the reverse way around (to the above example) ?

          TIA,
          Rich

          206
          MasterMaster
          206

            Jan 23, 2007#5

            A macro to insert your choice of characters at the beginning of each selected line. Assign to a keystroke for ease of use.

            InsertMode
            ColumnModeOff
            HexOff
            UnixReOff
            Find RegExp "%"
            Replace All SelectText "-- "
            Software For Metalworking
            http://closetolerancesoftware.com

            6,683583
            Grand MasterGrand Master
            6,683583

              Jan 23, 2007#6

              If you do not always have a space after the 2 dashes the macro is the only solution. If you always have a space after the 2 dashes, you can use following:

              Line Comment Num = 3--  Block Comment On Alt = --^

              Note: There are 2 spaces between 3-- and Block Comment.

              UltraEdit uses always the first line comment specification for the commands Comment Add and Comment Remove.

              By the way: Thanks to use the old thread with the same topic instead of creating a new one. Very well done!
              Best regards from an UC/UE/UES for Windows user from Austria

              3
              NewbieNewbie
              3

                Jan 23, 2007#7

                Great stuff, thanks to both of you - used a combination of both suggestions to meet 99% of my needs.

                Mofi's suggestion works most of the time, since there 'usually' a space following the --. Exceptions are occasional use of "-----------", for which I simply use mrainy's macro, searching instead for "%--" (resulting in "-- --------", which is fine)

                The other exception, which I'm stuck with is where I very occasionally insert -- to separate and 'deactivate' the rest of a line of code and prefer not to have a space. eg...

                Code: Select all

                val = a & b --& c
                I thought of a macro to colour some selected text (as per comments), then insert -- but couldn't find a macro command to set colour? And ultimately, life's just too short to be fussing about something this trivial!

                Thanks again for the help!

                6,683583
                Grand MasterGrand Master
                6,683583

                  Jan 23, 2007#8

                  Use following macro to insert a space after -- and the follwing character if the following character is not already a space, a ^ or a DOS line termination in current selection only or the whole file from current position to end of the file.

                  InsertMode
                  ColumnModeOff
                  HexOff
                  UnixReOff
                  IfSel
                  Find RegExp "--^([~ ^^^p]^)"
                  Replace All SelectText "-- ^1"
                  Else
                  Find RegExp "--^([~ ^^^p]^)"
                  Replace All "-- ^1"
                  EndIf
                  Best regards from an UC/UE/UES for Windows user from Austria

                  3
                  NewbieNewbie
                  3

                    Jan 23, 2007#9

                    Great stuff! Danke Mofi!

                    I was just too lazy to crank my rusty RegEx braincells back into action :-)