Comment fold strings in PowerShell UEW file

Comment fold strings in PowerShell UEW file

10
Basic UserBasic User
10

    Mar 10, 2014#1

    In Template for syntax highlighting language wordfile there is idea of open comment folding, such as

    Code: Select all

    /Open Comment Fold Strings = "#Region"
    /Close Comment Fold Strings = "#End Region"
    I'm not able to get this to work in v20.00.0.1056 with the PowerShell UEW file. I'm trying to use

    Code: Select all

    /Open Fold Strings = "{" "("
    /Close Fold Strings = "}" ")"
    /Open Comment Fold Strings = "#Region"
    /Close Comment Fold Strings = "#EndRegion"
    and then, in a PowerShell script, I have

    Code: Select all

    #Region blah
    blah
    blah
    #EndRegion blah
    As those are pretty standard in the PowerShell ISE. I get the correct comment color coding, but not the folding option.

    Has anyone gotten this to work?

    6,604548
    Grand MasterGrand Master
    6,604548

      Mar 10, 2014#2

      Does the wordfile contain in first line Line Comment = # ?

      Yes, than define the open/close comment fold strings with:

      /Open Comment Fold Strings = "Region"
      /Close Comment Fold Strings = "End Region"


      The open/close comment fold strings should be strings right of the line/block comment starting string.

      The syntax highlighting help page does not contain the line comment definition for the example

      /Open Comment Fold Strings = "#Region"
      /Close Comment Fold Strings = "#End Region"


      and therefore I just copied the example.


      I use comment fold strings in one of my wordfiles (doxyfile.uew) which has Line Comment = # in first line and

      /Open Comment Fold Strings = "-----"
      /Close Comment Fold Strings = "-----"


      That definition works fine.
      Best regards from an UC/UE/UES for Windows user from Austria

      10
      Basic UserBasic User
      10

        Mar 10, 2014#3

        Hmmm.....
        So the first line does contain "line comment = #", so I changed my fold strings to

        Code: Select all

        /Open Comment Fold Strings = "region"
        /Close Comment Fold Strings = "endregion"
        And that does NOT work.

        However, if I use your example,

        Code: Select all

        /Open Comment Fold Strings = "-----"
        /Close Comment Fold Strings = "-----"
        that works fine. Still working on it.

        6,604548
        Grand MasterGrand Master
        6,604548

          Mar 10, 2014#4

          I suppose your wordfile contains Line Comment = # as line comment = # would be ignored by UltraEdit.

          I played now a little with comment fold strings to find out possible reasons for your problem.

          First, if the first line does not contain the keyword Nocase in exactly this spelling, the words in the wordfile are case-sensitive. In this case the open/close comment fold strings are interpreted also case-sensitive and it maktes therefore a difference if region and endregion or Region and EndRegion is in wordfile/file to highlight.

          Second, the open/close comment strings in the file to highlight must be surrounded by delimiter characters as specified on the line starting with /Delimiters =. As I suppose that the file to highlight contains #Region and #EndRegion without a space or tab character between # and the open/close comment fold strings, it is necessary that the list of delimiter characters contains also # to get comment code folding working.

          It would be easier for me to help you if I could see the first lines in your wordfile up to /C1. Then I would not need to guess what your wordfile contains.
          Best regards from an UC/UE/UES for Windows user from Austria

          10
          Basic UserBasic User
          10

            Mar 10, 2014#5

            Code: Select all

            /L17"PowerShell" PS_LANG Nocase EnableMLS Line Comment = # Line Comment Alt = # Block Comment On = <# Block Comment Off = #> Escape Char = `\ String Chars = "' File Extensions = PS1 ps1 PSM1 psm1 psd1 PSD1 EnableSpellasYouType
            /Colors = 0,2255900,2255900,8421504,1580487,
            /Colors Back = 16777215,16777215,16777215,16777215,16777215,
            /Colors Auto Back = 1,1,1,1,1,
            /Font Style = 0,0,0,0,0,
            /Delimiters = :;(){}[] ,	
            /Indent Strings = "{" "if" "else" ":"
            /Unindent Strings = "}"
            /Function String  = "%[^t ]++^{[Ff]ilter^}^{[Ff]unction^}[ ^t]+^([-a-zA-Z0-9_]+^)"
            /Open Brace Strings =  "{" "(" "["
            /Close Brace Strings = "}" ")" "]"
            /Open Fold Strings = "{" "("
            /Close Fold Strings = "}" ")"
            /Open Comment Fold Strings = "region"
            /Close Comment Fold Strings = "endregion"

            6,604548
            Grand MasterGrand Master
            6,604548

              Mar 11, 2014#6

              Try the following block

              Code: Select all

              /L17"PowerShell" Nocase EnableMLS Line Comment = # Block Comment On = <# Block Comment Off = #> String Chars = "' Escape Char = ` EnableSpellasYouType File Extensions = PS1 PSM1 PSD1
              /Colors = 0,2255900,2255900,8421504,1580487,
              /Colors Back = 16777215,16777215,16777215,16777215,16777215,
              /Colors Auto Back = 1,1,1,1,1,
              /Font Style = 0,0,0,0,0,
              /Delimiters = # (	),:;[]{}
              /Indent Strings = "{" "if" "else" ":"
              /Unindent Strings = "}"
              /Function String  = "%[^t ]++^{filter^}^{function^}[^t ]+^([a-z0-9_^-]+^)"
              /Open Brace Strings =  "{" "(" "["
              /Close Brace Strings = "}" ")" "]"
              /Open Fold Strings = "{" "("
              /Close Fold Strings = "}" ")"
              /Open Comment Fold Strings = "region"
              /Close Comment Fold Strings = "endregion"
              Note: The multiple spaces between ( and ) must be replaced after pasting this block into the wordfile by a single horizontal tab character. Browsers display a tab character in a preformatted text as a sequence of spaces according to HTML standard.

              If the PowerShell script files now contain region and endregion (without a space) within a comment in any case, UltraEdit offers to fold the block between region and endregion. I have verified that with UE v21.00.0.1033 and an example file named Test.ps1.

              Mistakes in your original block:

              EnableSpellasYouType was appended at end of first line and therefore interpreted as file extension. After File Extensions = nothing else than file extensions can be listed.

              File extensions are always not case-sensitive. Therefore it is enough to specify them only in upper case or only in lower case.

              Line Comment Alt = # was a useless double definition of a line comment.

              It is only possible to specify 1 escape character for a single or a double quote in a single or double quoted string. I kept ` and removed \ as I don't know which escape character is more often used in PowerShell script files.

              # added to list of word delimiting characters as I have suggested in my previous post. The list of delimiters is additionally sorted according to ASCII list with the exception of the space and the tab character. The sort is not really necessary, but helps to see what is already in the list on longer lists than here.

              The UltraEdit regular expression search for finding strings for the function list is executed always not case-sensitive. Therefore it is not necessary to use [Ff] and [a-zA-Z] as that makes just the regular expression longer.
              Best regards from an UC/UE/UES for Windows user from Austria

              10
              Basic UserBasic User
              10

                Mar 11, 2014#7

                That seems to have done it. Thanks!