简体   繁体   中英

Is there a marker folding method in Intellij IDEA?

As an ex vimmer I would like to create persistent folds based on markers inside comments (eg // Section blabla {{{ , // End of blabla }}} ). Is it possible in Intellij IDEA ?

IntelliJ supports this feature, though the syntax is a bit different:

//<editor-fold desc="Properties">
private String foo;
private String bar;
//</editor-fold>

The value of desc attribute will be displayed when the region is folded. It can also be omitted entirely if you want.

You can easily surround selected code using Surround With/Editor fold comments action:

  • + ALT + T (OS X)
  • Control + ALT + T (Linux Windows)

You can also select to fold the custom regions by default in Settings/Editor/General/Code Folding by checking Custom folding regions checkbox.


Sources and additional information/screenshots:

The easiest syntax is probably this:

//region
...
all your code goes here
...
//endregion

And you can also give a description at the region part:

//region Getters & Setters
...
all your code goes here
...
//endregion

在此处输入图片说明

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM