Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

My Weekly NetBeans Tip (1): Surround with Code Folding

DZone's Guide to

My Weekly NetBeans Tip (1): Surround with Code Folding

· Java Zone ·
Free Resource

Verify, standardize, and correct the Big 4 + more– name, email, phone and global addresses – try our Data Quality APIs now at Melissa Developer Portal!

Code folding is a neat little feature that allows you to hide blocks of code, making a source file more readable. The XML syntax used by NetBeans isn't easy to remember, but this little trick will make it as easy as it gets:

1. Go to Tools> Options> Editor> Code templates

2. Click New, enter "cf" as the abbreviation, then enter the following code as the expanded text:

// <editor-fold defaultstate="collapsed" desc=" ${DESCRIPTION} ">
${selection line}${cursor}
// </editor-fold>

3. In the description tab, enter "Code folding", and click Ok

Now, if you select multiple lines of text in the editor, you will get the "light bulb" icon in the margin. Click it, and you'll get the option "Surround with Code folding". Select it, enter a description and you're done.

I found this tip here: http://wiki.netbeans.org/SurroundWithCodeFolding. I will be drawing attention here to other of my favorite tips once every week. Others should do the same!

Developers! Quickly and easily gain access to the tools and information you need! Explore, test and combine our data quality APIs at Melissa Developer Portal – home to tools that save time and boost revenue. 

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}