Can I use double quotes in Brace Matching?

Can I use double quotes in Brace Matching?

2
NewbieNewbie
2

    Apr 29, 2011#1

    Hello,
    I often edit lots of Unix shell scripts, so I need sometime use the character that double quotes as the Brace Match.
    but I found it isn't a good idea, UltraEdit's wordfile support single quotes and refuse double quotes.
    pls give me a good advice, thanks.

    My version of UE is 16.30.0.1003,
    Follow is my available line :
    /Open Brace Strings = "{" "[" "(" "`" "'" "if" "do" "case" "else"
    /Close Brace Strings = "}" "]" ")" "`" "'" "fi" "done" "esac" "fi"

    I try it several times, but failed when used these type :
    '"'
    "\""
    "\\""
    "\\\""
    """
    """"

    6,602548
    Grand MasterGrand Master
    6,602548

      Apr 29, 2011#2

      It is not possible to define the double quote character as brace string for match brace feature. The double quote character is used in the wordfile as delimiter character for the definition of the brace strings and no escape sequence is defined. Usually single or double quoted strings are highlighted as strings and therefore there is no need to use the match brace feature to find the matching double or single quote character. I suppose you have turned off string highlighting to get the words inside double quoted strings highlighted.

      If you execute match brace command usually by hotkey, I can offer a workaround. Create a macro with the same hotkey stored in a macro file which is set to be automatically loaded on startup of UltraEdit and remove the hotkey assignment from Match Brace command in the key mapping configuration dialog.

      IfCharIs """
      StartSelect
      Key RIGHT ARROW
      Find Select """
      EndSelect
      Else
      MatchBrace
      EndIf

      Note: Open/brace strings must be unique strings to get a correct working match brace feature. It is not possible that 2 open brace strings have the same close brace string and vice versa. Also the open brace string should be always different the close brace string, otherwise the match brace command can't find out into which direction it should search for the matching string, upwards or downwards.

      The macro solution above has therefore the limitation that you must set the caret at the opening double quote character to get everything up to next double quote character selected. The macro cannot automatically find out if the next double quote character should be searched downwards or upwards. Also it is not possible with the macro to set the caret anywhere inside a double quoted string and let it select on execution the entire double quoted string. If the character at caret position is not a double quote character, the macro always executes the match brace command. Also the macro is no help for an enabled auto-brace matching feature.

      2
      NewbieNewbie
      2

        Apr 29, 2011#3

        Thank Mofi very much.

        For your words, I have to cancel the idea about double quotes in the wordfile of unix shell scripts.

        But I still hope to see the improvement about double quotes character in Brace Matching at next new version, because the requirement is often referred when troubleshooting shell scripts error.

        thx.

        6,602548
        Grand MasterGrand Master
        6,602548

          Apr 29, 2011#4

          I'm quite sure, you will never see support of brace matching for double quotes nor for what you have already defined. Why?

          a) You have to request it by email from IDM support. Without a user request, nothing will be added ever.
          b) Using the same string for open and close "brace" string is simply not working for what is the feature designed for.
          c) Using the same close string for two different open strings is simply not working for what every programmer expects.

          The Match Brace feature is written for programmers and therefore must work as programmers need it.

          So if I'm looking on your definition of brace strings

          /Open Brace Strings = "{" "[" "(" "`" "'" "if" "do" "case" "else"
          /Close Brace Strings = "}" "]" ")" "`" "'" "fi" "done" "esac" "fi"

          the red marked one are already not fully working and will never fully work.

          I give you examples which show why it is simply necessary that every brace string is unique.

          First, a macro command: ReplInFiles Log "C:\Temp\" "*.tmp" " " " " ""

          What are the strings in this line? What are the matching double quotes? Do you have an idea? Yes, take a look here if you are right?


          Second, a CSV file example: double quote,34,0x22,"'""'","\"""


          Third, let us look on a possible shell script (taking into account that I don't know anything about Unix shell scripts):

          if (x!=y)
          command 1
          command 2
          else
          command 3
          command 4
          fi


          If you execute Match Brace command with caret left to if, it selects everything from if to fi. Is that correct? Yes! Really? Where does the if condition block really ends, on line with fi or on line with else? On line with else. You might want entire if else fi selected when using Match Brace command, but from the execution point of view the selection is wrong.

          Put now the caret inside command 1 and execute Match Brace command. It selects else fi block, but correct would be a selection of the if else block.

          Set the caret at beginning of else and execute Match Brace command. The else fi block is selected correct. Set the caret on character right inside the else or on line with command 3 or command 4 and execute Match Brace command. Selected is the entire if else fi block, but really correct would be a selection of just the else fi block.

          Code folding has no problem to correctly analyze an if else fi block and an if fi block with or without nesting other blocks when using

          /Open Fold Strings = "else" "if"
          /Close Fold Strings = "else" "fi"


          But code folding feature works with different rules than the match brace feature because of different requirements. The same is true when comparing string highlighting feature with match brace feature. The string highlighting feature is designed for highlighting single or double quoted strings with or without escaped single or double quotes inside the string, but not the match brace feature which is designed for a different goal.