Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create named code blocks in Intellij?

When Intellij generates code for UI forms you can collapse the code block and it is named: "UI Designer generated code". It is possible to collapse a code selection but its collapsed representation is displayed as "...". Is it possible to give it a custom name? It would look similar to a collapsed #region code block in C#.

like image 857
Eugen Avatar asked Apr 18 '11 17:04

Eugen


People also ask

How do I create a section in IntelliJ?

In the editor, press Ctrl+Alt+Insert to add a class, file, or package. If the focus is inside the Project tool window and you want to add a new element, press Alt+Insert . To create a new Scratch file, press Ctrl+Alt+Shift+Insert . IntelliJ IDEA creates a temporary file that you can run and debug.


1 Answers

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.

like image 158
Cel Avatar answered Oct 24 '22 21:10

Cel