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.
2 Answers
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.
Code folding is working now, in Xcode 9 Beta5 according to beta release note: Resolved in Xcode 9 beta 5 – IDE
Here is how:
- Press and hold ⌘ (command) button in keyboard and move/hover mouse cursor on any (start or end) braces. It will automatically highlight, block area.
- Keep (hold) ⌘ (command) button in pressed condition and click on highlighted area. It will enable quick menu popover window with
Fold
option. - Select
Fold
from menu list. It will fold your code and shows 3 dots, folding/covering entire block. - 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:
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:
-
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.– SAHMOct 18, 2017 at 16:44
-
Same situation in Xcode 9.1 beta 2 also. Apple may not revert/back with actual code folding ribbon.– KrunalOct 18, 2017 at 16:54
-
1I 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...– SAHMOct 18, 2017 at 16:58