Custom code folding in PHP editor improved

Posted by Petr Pisl on Jul 24 2008, 11:59:15 AM CEST

Last week I wrote article about code folding in PHP editor. Yesterday I have improved a little the custom fold. Now it allows to define, whether the fold will be by default collapsed and also the description of the fold.

From the picture should be clear that the custom fold is defined via element <editor-fold>, which can have two optional attributes. The attribute defaultstate with the value collapsed, says that the fold is collapsed when the file is opened. If you don't use this attribute, then the fold will not be collapsed after opening file by default. The second attribute is desc, where you can define a description of the fold. This description is displayed, when the fold is collapsed.

Because writing the open element can take time, you can create a code template for this.

  • Go to the Tools -> Options and in Editor category select Code Templates tab.
  • Select PHP in  Language combobox.
  • Press New button and enter an abbreviation for the code template. I have choosen cusf.
  • In the Expanded Text tex area write:

    <editor-fold defaultstate="collapsed" desc="${cursor}">

  • Close the Option dialog

The exresion ${cursor} marks the position, where cursor in editor is placed after expanding the code template.

Now when you write cusf and press TAB, then the text cusf is replaced with the defined template.

Category: Tips & Tricks | Permalink | Comments [8]

Trackback URL: http://blogs.sun.com/netbeansphp/entry/custom_code_folding_in_php
Comments:

Now this is getting some colors, looks really nice with the code template used to even ease the pain of writing kinda long element.
Code folding getting on a higher level of usability. I got to try it at home, for some time I can't do it at work, but seeing all of this - I think I'm going to use NetBeans a lot on a new pc here ;)

Posted by Azrael Valedhel on July 24, 2008 at 02:50 PM CEST #

The functionality is available in dev build and sure it will be a part of the M2/Beta build.

Thanks,
Petr

Posted by Petr on July 24, 2008 at 02:58 PM CEST #

thanks.

Posted by ci on July 25, 2008 at 09:50 AM CEST #

Hi,

Where can we go to submit feature requests?

Posted by raymond on July 25, 2008 at 05:16 PM CEST #

@raymond,
Here I believe http://www.netbeans.org/community/issues.html

Posted by alex_mayorga on July 25, 2008 at 05:23 PM CEST #

Why in last versions diff sidebar doesn't work? In version 200805291203 it's work normally.
Thanks.

Posted by Alexius on July 26, 2008 at 06:41 PM CEST #

Hi Alexius,

I haven't notice this. Do yo have the option View -> Show Diff Sidebar enabled?

Thanks,
Petr

Posted by Petr on July 28, 2008 at 10:11 AM CEST #

hi Petr:
Thanks your tutor about custom folding on php.!

i am using 6.5 beta. is there a setting to custom the html fold
like this:: i want to the fold

<div id="fold">the fold div's content is here</div> .

I want to get the effect is like this

<div id="fold">[..folding..]

thanks.

Posted by fortruth on August 28, 2008 at 03:25 PM CEST #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed