I have a bunch of code like this:
// methods related to Provider X
public void methodA() {...}
public String someOtherMethod {...}
public void increaseRankOfProviderX {...}
// end of 'methods related to Provider X'
I want IntelliJ to know this part as a block and I also want to collapse them, is there a way or plugin available I can achieve this in IntelliJ?
Two ways you can fold the code in IntelliJ IDEA:
NetBeans-like:
//<editor-fold desc="...">
... code ...
//</editor-fold>
VisualStudio-like:
//region <...>
... code ...
//endregion
Note that line commenting symbols for "region...endregion" can be changed from "//" to "#" if the '#' character is supported by a language. But by default custom folding comments use the same comment characters as normally used for language line comments.
Instead of typing the comments manually, in many cases you can invoke a 'Surround With' action for the highlighted code with Ctrl+Alt+T
: