14

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?

HaskellElephant
  • 9,819
  • 4
  • 38
  • 67
Gavin
  • 2,153
  • 2
  • 25
  • 35

2 Answers2

23

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.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • It works now, BTW. At least in the EAP build. Just surround your code in `#region` and `#endregion`. – mpen Apr 03 '12 at 16:44
  • @Nate See updated answer with correct link: http://blog.jetbrains.com/webide/2012/03/new-in-4-0-custom-code-folding-regions/ – LazyOne Aug 23 '13 at 08:58
  • @LazyOne Ah thanks - Would also like to note `#range` and `region` also work for folding – Nate-Wilkins Aug 23 '13 at 11:48
19

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
Brendan
  • 1,033
  • 10
  • 12