Keyboard shortcut for code folding in Xcode 9
Asked Answered
B

4

8

Code folding doesn't work with key binding Shift + Alt + Cmd + <- left in Xcode 9. Is anyone having same problem with Xcode 9?

Bootlick answered 7/7, 2017 at 19:20 Comment(0)
C
8

Code folding is one a long list of things that isn't implemented in the new editor yet.

UPD:

Now after release of Xcode 9 code folding works now with former shortcut ( Shift + Alt + Cmd + left arrow)

Note: For only folding the scope you are in, press Alt + Cmd + left arrow.

Civics answered 9/7, 2017 at 22:36 Comment(0)
S
16

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 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:

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

Surgical answered 18/8, 2017 at 12:20 Comment(0)
C
8

Code folding is one a long list of things that isn't implemented in the new editor yet.

UPD:

Now after release of Xcode 9 code folding works now with former shortcut ( Shift + Alt + Cmd + left arrow)

Note: For only folding the scope you are in, press Alt + Cmd + left arrow.

Civics answered 9/7, 2017 at 22:36 Comment(0)
T
4

It is the missing code-folding ribbon that is really making things incredibly difficult. I wouldn't have 'upgraded' if I had known.

Tarmac answered 4/10, 2017 at 0:40 Comment(0)
S
1

According to release notes. Code folding is not supported in Xcode 9.0.

The source editor in this beta version of Xcode 9.0 doesn’t support code folding. (29396003).

enter image description here

And as with all beta software, there are lots of open issues that are well documented in beta release notes.

Surgical answered 6/8, 2017 at 23:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.