« listopad 2009
PoÚtStČtSoNe
      
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
      
Today

Navigation

Speaker Profile
Roumen's Weblog
Login
Sun Bloggers
Technorati Profile

Am I popular?

Today's Page Hits: 1736

Contacts

Name: Roman Strobl
E-mail: roman dot strobl
at sun dot com

NetBeans

Java Sites

Javalobby
The Server Side
Java Tips
Java Blogs
java.net
java.sun.com
java.cz

Blogs

NetBeans:
Geertjan
Brian Leonard
Gregg Sporar
Lukas Hasik
Ludovic Champenois
Vincent Brabant
Alexis Moussine-Pouchkine
Jullion-Ceccarelli
Tom Ball
Tim Boudreau
Jesse Glick
Petr Blaha
Ruth Kusterer
Jara Uhrik
xzajo
Jan Lahoda
James Branam
nbextras.org

Sun:
Kazem - bug cartoons ;-)
Tor Norbye
Romain Guy
James Gosling
Chief Gaming Officer
Bill Vass
Jim Grisanzio
Jonathan Schwartz

Planets:
Planet Netbeans
Planet Sun
Planet Eclipse

Other:
netbeans-blog.org
Joel Spolsky
Bruce Eckel

License info

Creative Commons License
This work is licensed under a Creative Commons License.

Recent Entries

Map of visits

Locations of visitors to this page
« NetBeans IDE Field... | Main | Scripting Support... »
20050704 Pondělí červenec 04, 2005
NetBeans Quick Tip #8 - Using Custom Folds

I have a friend who is a vim fanatic. You recognize his code by seeing many {{{ and }}} strings all over the sources. These strings are used to define custom folds in vim. They're just everywhere, it makes the code much less readable in other editors. Well, isn't this a typical example of user lock-in? ;-) If you're not using vim, sorry, your eyes have to skip all those {{{s.

Anyway, obviously folding seems to be an important issue for some of the people. Today's NetBeans tip is for all folding deviants. Did you know that next to usual NetBeans folds you can define custom folds? Maybe you've mentioned it in J2EE classes or in Swing forms, but in case you didn't here's a short explanation.

To add your custom fold, use following piece of text:

// <editor-fold>
   Your code goes here...
// </editor-fold>

You can define default description of a collapsed fold like this:
// <editor-fold desc="This is my super secret genius code.">
   Your code goes here...
// </editor-fold>

You can set a fold to be collapsed by default this way:
// <editor-fold defaultstate="collapsed">
   Your code goes here...
// </editor-fold>

Happy folding!
Comments:

Hello from VIM fanatic ;-)
but is not
// {{{ <optional comment>
your code ...
// }}}
simpler, smaller and cuter then some long XML tags? :-P

Posted by Gilhad on červenec 06, 2005 at 11:36 dop. CEST #

You're right, it's shorter in vim ;-) But can you define description and default state in vim? I would be surprise if you would not...

Posted by Roman Strobl on červenec 06, 2005 at 05:32 odp. CEST #

There seems to be a small bug. If you use :-
<code> //<editor-fold desc="Start of auto generated elements" defaultstate="collapsed" > </code>
The "defaultstate" is shown in the comment but if you use:-
<code> //<editor-fold defaultstate="collapsed" desc="Start of auto generated elements"> </code>
It works correctly.

Posted by Nigel Leck on červenec 11, 2005 at 12:13 dop. CEST #

Oh, yes, that's a bug. I've filed it.

Posted by Roman Strobl on červenec 11, 2005 at 10:37 dop. CEST #

When will it be possible to just select a block of code and right-click on it, getting the option Create fold-block and have the XML-stuff generated by the IDE? <p/> Iwan

Posted by Iwan Eising on září 02, 2005 at 07:15 dop. CEST #

Iwan, thanks for all your suggestions. Why don't you file them into Issuezilla as enhancements? This way people can vote for them and somebody might create a patch for these features... you can of course try to develop it yourself, too :-) Thanks.

Posted by Roumen on září 03, 2005 at 03:10 odp. CEST #

Post a Comment:

Comments are closed for this entry.


    Disclaimer: The contents of my blog represent my personal opinions which may differ from official views of my employer, Sun Microsystems.