Enable code-folding by default Enable code-folding by default xcode xcode

Enable code-folding by default


If you want to fold / unfold specific blocks of code, since Xcode 7, you have to enable that.

Go to Xcode > Preferences > Text Editing > and check 'Code folding ribbon'.

Xcode's Text Editing preferences

(No idea why they disabled this useful feature by default.)


Not sure if this is an OS change, or an Xcode change, but on Lion with Xcode 4, some of these commands cited by Griffo are performed with the Option modifier (the ⌥ key), not control. I've made some changes to reflect this:

Fold                       ⌥⌘←      option+command+leftUnfold                      ⌥⌘→      option+command+rightUnfold All                  ⌥U        option+UFold Methods/Functions      ⌥⌘↑      option+command+upUnfold Methods/Functions    ⌥⌘↓      option+command+down

Sorry to necro a thread, but I thought this was worthwhile to revise.


Updates in Xcode 10:

Xcode 10 has increased support for code folding, including:

  1. A new code folding ribbon showing all of the multi-line foldable blocks of code in the editor
  2. A new style for folded code in the editor that allows you to edit lines with folded code
  3. Support for folding any block of code enclosed in curly braces
  4. Support for folding blocks of code from the folding ribbon, from structured selection, or from the

Menubar ► Editor ► Code Folding ► Fold menu item

enter image description here

Look at this snapshot:

enter image description here


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:

  1. Press and hold (command) button in keyboard and move/hover mouse cursor on any (start or end) braces. It will automatically highlight, block area.
  2. Keep (hold) (command) button in pressed condition and click on highlighted area. It will enable quick menu popover window with Fold option.
  3. Select Fold from menu list. It will fold your code and shows 3 dots, folding/covering entire block.
  4. 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:

enter image description here


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:

enter image description here

Same options from Xcode Short-cut list:

Menubar ▶ Xcode ▶ Preferences ▶ Key Bindings ▶ "Here is list of code folding short-keys"

enter image description here