Bracket/Braces Match Up available?

Just a question regarding nested code. Does Xcode have any feature whereby you can match up opening and closing brackets or braces by colour code, or something else, just to make it quicker to see which opening and closing braces or brackets are assiciated with one another?

Accepted Reply

If you hover the mouse over the vertical grey bar just at the right of line numbers, it selects the chunk of code for the matching braces. Hope it's clear (difficult sometimes without images).

Replies

a. You can double-click on an opening or a closing brace to select the entire scope.


b. If you move the text cursor (left or right arrow key) over a brace, the matching brace is temporarily highlighted.

If you hover the mouse over the vertical grey bar just at the right of line numbers, it selects the chunk of code for the matching braces. Hope it's clear (difficult sometimes without images).

I would love to make this too a correct answer as it is indeed answering my question and I will implement the first of your methods especially. I found the below method easier to see and read the relevant code block as it highlights it in a lighter colour rather than the other Xcode blue. Thank you for responding to my question, I very much appreciate it.

That's OK, I don't mind. 🙂


A couple of additional points, though:


1. The temporary highlighting I mentioned in (b) is useful when you're typing. It gives you a subtle confirmation that the "}" you just typed is matched to the correct "{", without having to stop and check via the code-folding ribbon that Claude mentioned. Both approaches are useful in context.


2. Both of things I mentioned work for all kinds of paired delimiters, not just braces: [ … ] and ( … ) and " … " and so on. Being able to select a whole string by double-clicking on the beginning or ending double-quote is useful, for example.

Hi Claude31,


What vertical grey bar just to the right of the numbers? I'm using Xcode 9 beta 5 and I have no such vertical bar. The only time I see anything remotely similar is if I use Xcode 9 b5's obnoxious code-folding feature to fold a chunk of code. Then I do have a grey vertical bar beside the first line number for that chunk but mousing over it does nothing.

I tested on 8.3.


I noticed there are still some limits on Beta9 editor.

Ok thanks Claude31. The original post was tagged xcode9 so I presumed we were talking about that.

Sorry - my bad. I updated the tags now. Meant to tag Xcode 8.