12 Replies
      Latest reply on Jun 13, 2019 5:22 AM by TonyAU
      bsabiston Level 1 Level 1 (20 points)

        Every IDE I have ever used (besides XCode) has a dead-simple way for you to find the matching brace in a piece of code.  You usually select one brace and then the other one is highlighted.

         

        XCode does this but only for like 1/100000 of a second, and it does not help when the brace is off the screen, which is the only time you really need this function.

         

        Is there a way to do it?  I know there used to be that way of folding up the entire scope so that it disappeared, but I always hated that, it was confusing and alarming, and besides I don't even see it anymore.

         

        Can somebody please let me know how to do it?  I am sure there is a way and I don't see it -- why don't they just do it like everyone else does?

        • Re: Xcode: how to see matching brace?
          QuinceyMorris Level 8 Level 8 (6,040 points)

          Xcode highlights an opening delimiter (brace, bracket, parenthesis) when you move the cursor left-to-right over the matching closing delimiter. The highlight animation lasts about 1 second total, which is plenty in the case where you need a hint (and as you say the other delimiter is nearby).

           

          If you need a more persistent indication, you can double-click either the opening or the closing delmiter, and Xcode will select both delimiters and their contents. (You can also use this, for example, to get quickly to one delimiter from another, even if they're far apart — double-click the delimiter you can see, use the left or right arrow to get the the other end of the selection.)

           

          Presumably, they don't "just do it like everyone else does" because Xcode has done it this way for many, many years and people who actually use Xcode are used to it and would prefer that it wasn't arbitrarily changed on them.

           

          C# (for example) has a non-selection highlighting mechanism that's useful, but it also results in your source code lighting up, sometimes, in a chaos of garish colors. So it's pretty much a personal choice which unpleasant side effects you prefer.

           

          Still, this is the sort of thing you should submit a bug report about, since that's how the popularity contest for new features works. If enough people ask for it, Apple may well change or enhance the current behavior.

            • Re: Xcode: how to see matching brace?
              bsabiston Level 1 Level 1 (20 points)

              Thanks!  While I think this is a rare instance of everyone else doing it better than Apple, just knowing how to do it is really all I need.  I've been using XCode as long as it's been around and never have known that double-click thing.  It never bothered me until recently, when I have been using both VS 2013 and GameMaker and have begun to appreciate just putting the cursor on a brace and having the other one light up (for more than a second).

            • Re: Xcode: how to see matching brace?
              JunhoHan Level 1 Level 1 (0 points)

              Do all the developer in Apple write functions shortly like that?

              So, Their functions can be shown up in one page of their monitor?

              And!!

              Double-Click?? I cannot write codes using my mouse.

              Should I move my right hand to the mouse when I wanna just check the brace??

              I think they must make another way....

              • Re: Xcode: how to see matching brace?
                TonyAU Level 1 Level 1 (0 points)

                Double-clicking on the curly brace not only highlights the block but also jumps to the start (or end) of the block. So it is like the keyboard short cuts most IDEs provide except that it is a mouse double-click not a key press. I don't see any reason why they couldn't add a keyboard shortcut for it as well though.

                Another case of XCode doing things differently to most other IDEs is getting to the start or end of the file. It took me ages to find out how to do this in XCode without needing to drag the scroll bar with the mouse. The XCode short-cuts are Command-up, and Command-down. (Ctrl-PageUp and Ctrl-PageDown would make more sense to me).

                It would be really nice if Apple at least tried to make life a bit easier for developers who also use popular IDEs like Visual Studio and Intelli J.