how to jump to close brackets

how to jump to close brackets

3
NewbieNewbie
3

    Jan 15, 2009#1

    Hi,
    is there any KEY I can use to jump to close brackets while I edit files?

    { // edit here, and press a hotkey, then jump to close brackets
    abccvc

    //jump to here}

    6,606548
    Grand MasterGrand Master
    6,606548

      Jan 15, 2009#2

      Search - Match Brace can be used. It selects everything between matching braces and sets the cursor to the opening brace or if the cursor is already on the opening brace, it sets the cursor on the matching closing brace.

      So you need to press the hotkey for Search - Match Brace twice and key RIGHT or LEFT to unselect and continue editing.
      Best regards from an UC/UE/UES for Windows user from Austria

      3
      NewbieNewbie
      3

        Jan 16, 2009#3

        I found the solution. I should set the cursor before "{", then I can match whole brackets.

        Thanks for your help.

        6,606548
        Grand MasterGrand Master
        6,606548

          Jan 16, 2009#4

          Don't know which version you use, but if I execute Match Brace while the cursor is inside { .... } the whole block is selected and the cursor is set left to the opening brace. Second Match Brace moves cursor to the closing brace.

          To be more precise: First match brace with cursor anywhere in the code searches for next opening { ( [ or closing } ) } and selects the block defined by the found brace.
          Best regards from an UC/UE/UES for Windows user from Austria

          3
          NewbieNewbie
          3

            Jan 16, 2009#5

            I am using lastest version, 14.20.xxx and default setting/install.

            | {A (B) }
            if cursor before {, it match "{A (B) }"

            {A |(B) }
            if here, it match (B)

            6,606548
            Grand MasterGrand Master
            6,606548

              Jan 16, 2009#6

              Yes, that's the behaviour I wanted to explain in my previous post. Of course you can configure which "strings" (braces, brackets) you want to be found by the match brace function.

              The standard in the wordfile for most languages is:

              /Open Brace Strings = "{" "(" "["
              /Close Brace Strings = "}" ")" "]"

              But if you change that to:

              /Open Brace Strings = "{" "["
              /Close Brace Strings = "}" "]"

              then also with the cursor located as written in your second example whole {A (B) } will be matched, (B) is ignored now.

                Jan 18, 2009#7

                I have another idea how to always jump right to the matching } without changing the brace strings in the wordfile. This solution gives you the possibility to use the Match Brace command for {}, () and [], and additionally you can use a different hotkey to always jump to matching } independent of the current cursor position.

                You have to copy following macro code lines into a new macro using the Edit Macro dialog. You can specify any name for the macro. Important is that you disable first macro property Show Cancel dialog for this macro, but enable the second macro property Continue if search string not found. And of course you should specify a hotkey for the macro to be able to fast execute it at any time later.

                IfCharIs "{"
                Else
                Find MatchCase Up "{"
                IfNotFound
                Find MatchCase "{"
                IfNotFound
                ExitMacro
                EndIf
                EndIf
                EndSelect
                Key LEFT ARROW
                EndIf
                MatchBrace
                IfSel
                EndSelect
                Key LEFT ARROW
                Key RIGHT ARROW
                EndIf

                Please insert at top of this macro the command for the regular expression engine you prefer to use (UnixReOff or UltraEditReOn, UnixReOn, PerlReOn). The macro does not run regular expression searches, but also non regular expression searches are done with one of the 3 search engines and therefore it should be specified which one.

                You should save the macro into a macro file (probably with other macros) which is specified at Macro - Set Auto Load for automatic loading on startup of UltraEdit. Then the macro file with this special macro is automatically loaded on startup of UltraEdit and you just have to press the macro hotkey to execute the macro and position the cursor right of next matching }.

                Here is the macro code again with indentations for easier reading and understanding:

                Code: Select all

                IfCharIs "{"
                Else
                    Find MatchCase Up "{"
                    IfNotFound
                        Find MatchCase "{"
                        IfNotFound
                            ExitMacro
                        EndIf
                    EndIf
                    EndSelect
                    Key LEFT ARROW
                EndIf
                MatchBrace
                IfSel
                    EndSelect
                    Key LEFT ARROW
                    Key RIGHT ARROW
                EndIf
                Best regards from an UC/UE/UES for Windows user from Austria