tri
tri

Reputation: 371

How to show(unfold) the hidden(folded) code in Intellij-IDEA with keyboard shortcut?

How can I show(unfold) the hidden(folded) code in IntelliJ IDEA, as shown in the picture below, just using keyboard without touching the mouse?

hidden code in intelliJ IDEA

Upvotes: 25

Views: 9072

Answers (4)

Saikat
Saikat

Reputation: 16760

Easy to remember steps:

  • Press SHIFT twice
  • Type folding
  • Select Folding action
  • All options related to Expand and Collapse should be visible now (with keymaps)

Upvotes: 0

DimaSan
DimaSan

Reputation: 12684

In IntelliJ IDEA you can use to following shortcuts to fold/unfold code blocks:

  • To fold and unfold CURRENT selected block of code:
    • CTRL+- and CTRL++ on Windows;
    • ⌘ CMD+- and ⌘ CMD++ on Mac;
  • To fold and unfold ALL blocks of code:
    • CTRL+⇧ SHIFT+- and CTRL+⇧ SHIFT++ on Windows
    • ⌘ CMD+⇧ SHIFT+- and ⌘ CMD+⇧ SHIFT++ on Mac.

By the way, in Settings → Editor → General → Code Folding you can specify the default folding behavior for a various situations (e.g., imports, one-line methods, inner classes, @SuppressWarnings annotations, array literals, generic constructors and many others):

enter image description here

And even after that your folding/unfolding hotkeys listed above will work as well.

Upvotes: 33

Supun Wijerathne
Supun Wijerathne

Reputation: 12948

The only available option for your need (about import statements) is,

  • Move your pointer to (+) button on the left hand side of the statement so you can see the pointer changes to hand mark. enter image description here

  • Then Ctrl + -

Find this for more info expanding/collapsing code. But this is more about blocks.

Upvotes: 3

Frederic Close
Frederic Close

Reputation: 9639

To be sure which shortcuts are available go to settings > Keymap

then go to

Main Menu > Code > Folding

Expand default on mac : cmd+ default on win : ctrl + numpad + Collapse default on mac : cmd- default on mac : cmd- default on win : ctrl + numpad -

enter image description here

Upvotes: 5

Related Questions