Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make intelliJ idea display folding toggles for "if" statement?

I'm using intelliJ IDEA and by default, it displays a pair of folding toggles for methods and javadoc comments, but not "if", "for" or "while" statements:

I wonder if there is a way to display toggles for all the code blocks surrounded by braces?

PS: too bad that I cannot upload an image. Hope you can understand what I'm talking about.

like image 312
Yuqing Avatar asked May 26 '15 06:05

Yuqing


People also ask

How do you fold in IntelliJ?

To fold or unfold a code fragment, press Ctrl+NumPad - / Ctrl+NumPad + . IntelliJ IDEA folds or unfolds the current code fragment, for example, a single method. To collapse or expand all code fragments, press Ctrl+Shift+NumPad - / Ctrl+Shift+NumPad + .

How do I stop IntelliJ from collapsing?

Open 'Settings' from the File menu. Under 'Editor' -> 'General' -> 'Code Folding', you will find a 'Collapse by Default' section. Simply uncheck 'One-line methods' and click OK.


1 Answers

You can fold any code block with Ctrl+Shift+. (also available in the Code → Folding menu).

Ctrl+. (same menu) folds a selection.

(Use instead of Ctrl on OSX.)

like image 78
Steve Chaloner Avatar answered Oct 12 '22 11:10

Steve Chaloner