Is anyone having problem with code folding in Xcode 8? Every time I fold GameScene.swift
(or any other file), switch to, for example, AppDelegate.swift
, and switch back to GameScene.swift
(which were folded before), it unfolds.
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.
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.
Xcode unfortunately neither store nor remembers code folding. It actually resets folded parts after losing focus that file.
Since the code folding is reset all the time, I personally use this way of refolding:
To fold all the methods: Shift + Alt + Cmd + <- left
Place cursor onto the desired method and unfold it by clicking or using shortcut: Alt + Cmd + -> right
With Xcode-9, this issue is resolved. Code folding is being remembered and saved by Xcode 9 Editor.
Code you have/had folded exact before last source build/save, is automatically stored upon document/file closure. And same will be visible as it was (folded) when you will open document/file next time.
You don't need to do anything (there is no any option in Xcode tool bar to enable or disable) to save your code fold.
Here are some keyboard short cuts for code folding:
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
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