3

The side bar, next to the code line numbers, that allows expansion/collapsing of brace/brackets {} is no longer showing in Xcode. I am trying to figure out how to get it back.

Krunal
  • 68,602
  • 40
  • 230
  • 241
SAHM
  • 3,747
  • 4
  • 37
  • 77

2 Answers2

13

Go to Xcode Preferences/Text Editing and check the "Code Folding Ribbon" box.

EDIT: As of Version 9.0.1 (9A1004), this feature has been removed from Xcode 9. I am looking for a new editor because I use this feature so much, and I cannot believe they actually removed it in Xcode 9.

SAHM
  • 3,747
  • 4
  • 37
  • 77
10

Code folding is working now, in Xcode 9 Beta5 according to beta release note: Resolved in Xcode 9 beta 5 – IDE

Here is how:

  1. Press and hold (command) button in keyboard and move/hover mouse cursor on any (start or end) braces. It will automatically highlight, block area.
  2. Keep (hold) (command) button in pressed condition and click on highlighted area. It will enable quick menu popover window with Fold option.
  3. Select Fold from menu list. It will fold your code and shows 3 dots, folding/covering entire block.
  4. Now, to again unfold your code block, release (command) button and click on 3 dots folding a block.

For easy understanding, look at this snapshot:

enter image description here

It's all keyboard short cuts are also working.

Fold                        ⌥ ⌘ ←      option + command + left arrow
Unfold                      ⌥ ⌘ →      option + command + right arrow
Unfold All                  ⌥ U        option + U
Fold Methods/Functions      ⌥ ⌘ ↑      option + command + up arrow
Unfold Methods/Functions    ⌥ ⌘ ↓      option + command + down arrow

Here is ref snapshot:

enter image description here

ROOT
  • 10,339
  • 5
  • 24
  • 40
Krunal
  • 68,602
  • 40
  • 230
  • 241
  • But the code folding ribbon is missing in Xcode 9 and even in the Version 9.0.1 (9A1004) release - which makes code-folding virtually unusable for me. I never realized how much I use that ribbon until it is gone. I can't actually believe that they took such a useful tool out of Xcode. I am hoping this is just temporary. – SAHM Oct 18 '17 at 16:44
  • Same situation in Xcode 9.1 beta 2 also. Apple may not revert/back with actual code folding ribbon. – Krunal Oct 18 '17 at 16:54
  • 1
    I can't believe that would be true. I fold/unfold large blocks of codes within functions all of the time, and the old ribbon was perfect. Now, in Xcode 9 - 1) can't find a way to do this in functions and 2) even if we could, everything takes so many more steps now. I can't even fold two blocks and try to remove the space between them because it ends up deleting one of the blocks! The worst editing experience I can imagine. I can't believe that *some* higher-up Apple employee developer wouldn't have anything to say about this... – SAHM Oct 18 '17 at 16:58