Code folding lets you collapse (fold) code blocks, reducing them to a single visible line. In this way, you can hide the details that, at the moment, seem unimportant. If and when necessary, the folded code blocks can be expanded (unfolded).

Folded code blocks are shown as shaded ellipses.

You can fold (collapse) and unfold (expand) code blocks by using:

  • Code folding toggles (foldingMinusStart, foldingMinusEnd or foldingPlus). These toggles are shown in the editor on the left of the corresponding blocks. If a block is unfolded, foldingMinusStart indicates the beginning of the block while foldingMinusEnd is located at its end. For folded blocks, the toggle is shown as foldingPlus.

    If you hold the Alt modifier and click a toggle button in the gutter, the code block will be collapsed or expanded recursively, i.e. all sub-blocks within the parent block will also be collapsed or expanded.

  • Commands of the Folding menu. The Folding menu can be accessed from the main menu bar (Code | Folding), or as a context menu in the editor.
  • Keyboard shortcuts. The corresponding shortcuts are shown in the Folding menu.

Folding menu

ItemShortcutDescription
Expand Ctrl+NumPad Plus or Ctrl+Equals Expand the current code block
Collapse Ctrl+NumPad - or Ctrl+Minus Collapse the current code block
Expand Recursively Ctrl+Alt+NumPad Plus or Ctrl+Alt+Equals Expand all sub-blocks within the current code block
Collapse Recursively Ctrl+Alt+NumPad - or Ctrl+Alt+Minus Collapse all sub-blocks within the current code block
Expand All Ctrl+Shift+NumPad Plus or Ctrl+Shift+Equals Expand all code blocks in the selected area, or in the current file if no area is selected
Collapse All Ctrl+Shift+NumPad - or Ctrl+Shift+Minus Collapse all code blocks in the selected area, or in the current file if no area is selected
Expand to level Ctrl+NumPad *, 1 or Ctrl+NumPad *, NumPad-1
Ctrl+NumPad *, 2 or Ctrl+NumPad *, NumPad-2
Ctrl+NumPad *, 3 or Ctrl+NumPad *, NumPad-3
Ctrl+NumPad *, 4 or Ctrl+NumPad *, NumPad-4
Ctrl+NumPad *, 5 or Ctrl+NumPad *, NumPad-5
Expand the selected code block to a certain level
Expand all to level Ctrl+Shift+NumPad *, 1 or Ctrl+Shift+NumPad *, NumPad-1
Ctrl+Shift+NumPad *, 2 or Ctrl+Shift+NumPad *, NumPad-2
Ctrl+Shift+NumPad *, 3 or Ctrl+Shift+NumPad *, NumPad-3
Ctrl+Shift+NumPad *, 4 or Ctrl+Shift+NumPad *, NumPad-4
Ctrl+Shift+NumPad *, 5 or Ctrl+Shift+NumPad *, NumPad-5
Expand all code blocks in the current file to a certain level
Expand doc comments N/A Expand all documentation comments in the current file
Collapse doc comments N/A Collapse all documentation comments in the current file
Fold Selection / Remove region Ctrl+Period Collapse the selected fragment / Expand the selected fragment and make it "unfoldable"

In this section:

See Also

Reference:

Web Resources: