Custom code folding in PHP editor improved

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.

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 07:50 AM 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 07:58 AM CEST #

thanks.

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

Hi,

Where can we go to submit feature requests?

Posted by raymond on July 25, 2008 at 10:16 AM CEST #

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

Posted by alex_mayorga on July 25, 2008 at 10:23 AM 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 11:41 AM 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 03: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 08:25 AM CEST #

This is a very nice feature. I'd love to see this for JavaScript too (though even better would be to see objects--which can be quite long--be made collapsible).

Posted by Brett Zamir on October 18, 2008 at 07:55 PM CEST #

I want to go through all languages (html, css, javascript and php) and synchronize functionality more. Folding should be one of them.

Thanks,
Petr

Posted by Petr on October 19, 2008 at 04:02 PM CEST #

Hi there,
thanks a lot for this artikel and the tipps in it.
I am quiet new to development with netbeans. (I use german language pack on it)
I have a problem with code folding.
It folds the code, but when i place the mouse over the hidden field (where code is hidden) it only shows me a empty box, just with the line numbers in of the part of the hidden code. It looks like the first picture on this side, but it looks like you have only the first 30 pixels from the left side.

Hope i described my problem clear enough. It would be nice if you have any tipps for me.
Best regards
Ben

Posted by Ben on August 12, 2010 at 02:25 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

This blogs is written by NetBeans developers who contribute to the PHP support mainly.

Search

Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today