Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhpStorm define collapsible code regions (Visual Studio style Regions) possible?

In Visual Studio you can use #region and #endregion to wrap developer defined blocks of code.

I would love to see this functionality in PhpStorm, it is an ideal way to organise a large source file (for example lots of interface implementations).

Is it possible to make PhpStorm behave this way?

like image 690
Gavin Avatar asked Aug 16 '11 10:08

Gavin


2 Answers

Sorry, currently it is not possible.

Please vote and watch this ticket: https://youtrack.jetbrains.com/issue/WI-261


UPDATE

It's now implemented (since PhpStorm v4) -- check PhpStorm's blog for details: http://blog.jetbrains.com/webide/2012/03/new-in-4-0-custom-code-folding-regions/


//<editor-fold desc="Region">

// Your code goes here

//</editor-fold>

Default collapse state is also properly supported now (as of PhpStorm v8, IIRC), although you have to add such part yourself manually. e.g.

//<editor-fold defaultstate="collapsed" desc="Region">

P.S. #region syntax (Old MSDN link / current 2022 docs link) is also supported.

like image 171
LazyOne Avatar answered Oct 21 '22 06:10

LazyOne


I was looking for this too, and find that it's available for use now in version 4 EAP.

Working example:

// region Private members
private $db;
private $cache;
// endregion
like image 16
Brendan Avatar answered Oct 21 '22 06:10

Brendan