Jump to matching brace in Xcode

Viewed 322

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.

3 Answers

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 ⌥⌘←.

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.

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".)

Related