I know code folding was missing in the early Beta's of Xcode9 and that it is available to fold entire methods with CMD click.
But in Xcode 8 i was able to fold code in blocks (i.e. individual if statements) via Editor >> Code Folding >> Fold but in Xcode 9 this folds the entire method.
Is there a fix/setting i can change to restore the Xcode 8 functionality?
Just to the right of line numbers you will see a new ribbon with up or down arrows next to functions / methods. Pressing these will allow you to expand or collapse functions / methods.
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.
Updates in Xcode 10
Xcode 10 has increased support for code folding, including:
Menubar ► Editor ► Code Folding ► Fold menu item
Look at this snapshot:
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:
⌘
(command) button in keyboard and move/hover mouse cursor on any (start or end) braces. It will automatically highlight, block area.⌘
(command) button in pressed condition and click on highlighted area. It will enable quick menu popover window with Fold
option.Fold
from menu list. It will fold your code and shows 3 dots, folding/covering entire block.⌘
(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 Fold Comment Blocks ⌃ ⇧ ⌘ ↑ control + shift + command + up Unfold Comment Blocks ⌃ ⇧ ⌘ ↓ control + shift + command + down Focus Follows Selection ⌃ ⌥ ⌘ F control + option + command + F Fold All ⌘ ⌥ ⇧ ← command + option + shift + left Unfold 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"
It is stated in the release notes that it is not supported as of yet.
You can fold individual if
statements also in Xcode 9 however it folds the entire if - (else)
expression.
Put the cursor somewhere within the block and press ⌥⌘←
Unfolded:
Folded:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With