skip to Main Content

In Xcode, if the cursor is on one brace (or bracket or parenthesis) of a matched pair, what keyboard shortcut will jump to the matching brace? Or how can I create such a shortcut?

An example of the feature I’m after is the "goto brace" shortcut in Visual Studio.

4

Answers


  1. Chosen as BEST ANSWER

    A partial solution is to use code folding. For example, to jump from the opening brace to the closing brace:

    1. Put the cursor just after the opening brace.
    2. Fold with ⌥⌘←.
    3. Arrow the cursor right to just before the closing brace.
    4. Unfold with ⌥⌘←.

  2. Since Xcode now has Vim mode you can use that and just hit %.

    (Adding this answer for completeness – I understand it kind of amounts to "just use Vim".)

    Login or Signup to reply.
  3. There is a Balance Delimiters menu command. So simply assign it any keyboard shortcut you prefer (all commands have customizable key bindings). You can also double-click the first delimiter to perform the same action.

    Login or Signup to reply.
  4. I had the same question and found a way to do this quickly, but it’s not a keyboard shortcut (you have to use the mouse):

    1. Double-click on the brace. This selects the brace, the closing brace, and everything in between.
    2. Type right-arrow. This de-selects everything and places the cursor after the closing brace.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search