Enabling Code Folding Bar in Xcode
I always encounter this that suddenly I accidentally hide the Code folding ribon. So from @PetahChristian's answer, I captured it with screenshot.
Xcode > Preferences > Text Editing > Check "Code Folding Ribbon"
Code folding was disabled in Xcode 9 beta 1, which 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 withFold
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 arrowUnfold ⌥ ⌘ → option + command + right arrowUnfold All ⌥ U option + UFold Methods & Functions ⌥ ⌘ ↑ option + command + up arrowUnfold Methods & Functions ⌥ ⌘ ↓ option + command + down arrowFold Comment Blocks ⌃ ⇧ ⌘ ↑ control + shift + command + upUnfold Comment Blocks ⌃ ⇧ ⌘ ↓ control + shift + command + downFocus Follows Selection ⌃ ⌥ ⌘ F control + option + command + FFold All ⌘ ⌥ ⇧ ← command + option + shift + leftUnfold All ⌘ ⌥ ⇧ → command + option + shift + left
Code folding options from Xcode Menu:
Menubar ► Editor ► Code Folding ► "Here is list of code folding options"
Here is ref snapshot:
Same options from Xcode Short-cut list:
Menubar ► Xcode ► Preferences ► Key Bindings ► "Here is list of code folding short-keys"