How to create named code blocks in Intellij?
They have implemented region-support now!
From http://youtrack.jetbrains.com/issue/IDEA-80636
Currently Intellij IDEA supports two basic types of custom folding comments:
NetBeans-like:
//<editor-fold desc="...">
... code ...
//</editor-fold>
And 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 use Ctrl+Alt+T (surround with). Please submit separate issues if you find that something doesn't work as expected.
There is a shortcut for that:
Open Surround with
menu, by pressing
Linux/Windows: Ctrl +Alt+T
Mac: Option ⌥+Command ⌘+T
And than choose <editor-fold...> Comments
option
Or you can do it manually.
For Java/Scala it is:
//<editor-fold desc="DESCRIPTION">
___YOUR_CODE___
//</editor-fold>
For Python it's almost the same
# <editor-fold desc="DESCRIPTION">
___YOUR_CODE___
# </editor-fold>
Example:
//<editor-fold desc="Main">
public static void main(String[] args) {
System.out.println("Hello World");
}
//</editor-fold>