Search code examples
intellij-ideaintellij-14

How to fold try/catch, switch, for, while and if statements in IntelliJ Idea?


IntelliJ Idea fold if and other statements in JavaScript, but not in Java. How can I get this feature? Maybe you know some plugin or settings?


Solution

  • I don't think that it's possible from Code > Folding or using the icons from the left bar (collapse/expand), but you can do it in a harder way: manually.

    E.g.:

    • select the try block
    • Code > Folding > Fold Selection / Remove Section ( Ctrl + Period, where Period is the .)
    • you'll see ... instead of that block
    • now that block also has the icons for collapse/expand on the left bar