How to collapse all methods in a class in Xcode?
Collapsing one by one is not an option anymore.
How to collapse all methods in a class in Xcode?
Collapsing one by one is not an option anymore.
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:
Fold
option.Fold
from menu list. It will fold your code and shows 3 dots, folding/covering entire block.For easy understanding, look at this snapshot:
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 + right
Here is ref snapshot:
Same options from Xcode Short-cut list:
Menubar ▶ Xcode ▶ Preferences ▶ Key Bindings ▶ "Here is list of code folding short-keys"
Unfold All
appears twice in your shortcuts list –
Interclavicle As of Xcode 4 it seems to have changed.
command-alt-shift-left arrow will do the trick...
To fold/unfold current methods or if
structures use:
Fold: command-alt-left arrow
Unfold: command-alt-right arrow
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:
Fold
option.Fold
from menu list. It will fold your code and shows 3 dots, folding/covering entire block.For easy understanding, look at this snapshot:
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 + right
Here is ref snapshot:
Same options from Xcode Short-cut list:
Menubar ▶ Xcode ▶ Preferences ▶ Key Bindings ▶ "Here is list of code folding short-keys"
Unfold All
appears twice in your shortcuts list –
Interclavicle X-Code 7 onwards
To collapse all method : Shift + Option + Command + Left arrow
To expand all method : Shift + Option + Command + Right arrow
I like this table from Krunal's answer (above) : https://mcmap.net/q/116635/-how-to-collapse-all-methods-in-xcode
Fold ⌥ ⌘ ← option + command + left arrow
Unfold ⌥ ⌘ → option + command + right arrow
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 + right
Looks like Ctrl-Command-Up does it (or on the menu: Editor-CodeFolding-FoldMethods/Functions).
Ctrl-Command-Down or Ctrl-U to reverse.
Press COMMAND + , "command comma"
Click "Text Editing" tab
Check "Code Folding Ribbon"
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.
Shift + Option + Command + Left arrow, did not work for me. A work around I have found if use "Find" and put in "[". use "Return" to skip to arrays. When you come to one you want to close, use the "Option + Command + Left arrow". you can very quickly close a lot of array without ever clicking
© 2022 - 2024 — McMap. All rights reserved.