MPS 2024.1 Help

Fold and unfold (collapse/expand) code fragments

You can collapse (fold) code fragments to a single visible line, hiding the details that are unimportant at the moment. When necessary, folded code fragments can be unfolded (expanded).

Folded code fragments are shown as shaded ellipses (MPS: Folded code block in the editor).

If the folded code block contains errors, the ellipses are displayed in red .

To see the contents of a folded block, hover over the folding ellipsis MPS: Folded code block in the editor.

What to fold and unfold

  • Predefined regions that correspond to import declarations, method bodies, documentation comments, and so on.

    You can fold and unfold predefined regions using the folding arrows on the gutter and dedicated keyboard shortcuts.

  • Any selected code fragment can be folded by pressing Ctrl+. or choosing Code | Folding | Fold Selection / Remove Region from the menu.

How to fold and unfold

  • Use code folding arrows (, , and ) in the editor gutter.

    You can configure whether and how to show the folding arrows on the Editor | General | Code Folding page of settings  Ctrl+Alt+S.

  • Use the commands of the Folding menu and associated keyboard shortcuts.

  • Click folded fragment in the editor to unfold a folded block.

Commands of the Folding menu and associated shortcuts

The Folding menu can be accessed from the main menu (Code | Folding), or as a context menu in the editor.

Command

Shortcut

Description

Collapse

Ctrl+NumPad -

Collapse the foldable block where your caret is..

Expand

Ctrl+NumPad +

Expand the collapsed block under the caret.

Collapse Recursively

Ctrl+Alt+NumPad -

Collapse the current foldable block and all foldable blocks within it.

Expand Recursively

Ctrl+Alt+NumPad +

Expand the collapsed block under the caret all the collapsed blocks within it.

Expand All

Ctrl+Shift+NumPad +

Expand all collapsed blocks in the document or within the selection.

Collapse All

Ctrl+Shift+NumPad -

Collapse all foldable blocks in the document or within the selection.

Expand all to level | 1, 2, 3, 4 or 5

  • Ctrl+Shift+NumPad *, 1

  • Ctrl+Shift+NumPad *, 2

  • Ctrl+Shift+NumPad *, 3

  • Ctrl+Shift+NumPad *, 4

  • Ctrl+Shift+NumPad *, 5

Expand all the folded blocks in the document up to the specified nesting level.

Collapse doc comments

Collapse all documentation comments in the current document.

Expand doc comments

Expand all documentation comments in the current document.

Fold Selection / Remove region

Ctrl+.

Collapse the selected fragment and create a custom folding region for it to make it 'foldable' or expand the current fragment and remove the corresponding custom folding region.

Configure code folding preferences

MPS allows you to configure:

  • Whether and how to show the code folding arrows.

  • Which folding regions should be collapsed by default.

You can change the corresponding settings on the Editor | General | Code Folding page of settings  Ctrl+Alt+S.

Last modified: 28 June 2024