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?
4 Answers
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):
And even after that your folding/unfolding hotkeys listed above will work as well.

- 12,264
- 11
- 65
- 75
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 -

- 9,389
- 6
- 56
- 67
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.
Then Ctrl + -
Find this for more info expanding/collapsing code. But this is more about blocks.

- 11,964
- 10
- 61
- 87
Easy to remember steps:
- Press SHIFT twice
- Type
folding
- Select
Folding
action - All options related to
Expand
andCollapse
should be visible now (with keymaps)

- 14,222
- 20
- 104
- 125