kravemir
kravemir

Reputation: 10996

How to quickly create editor fold?

When I was editing GUI class I've found editor fold.

// <editor-fold defaultstate="collapsed" desc="Generated Code">
...
// </editor-fold>

I've started using it for my own purposes, but it's couple of words to write. So I'm looking for any faster way.

Upvotes: 26

Views: 22933

Answers (4)

Kang Jie Ming
Kang Jie Ming

Reputation: 321

In Netbeans, you can type 'fcom' and press 'TAB'.

More shortcuts here

Upvotes: 32

Francois Dermu
Francois Dermu

Reputation: 4491

The previous solutions didn't work for me (maybe because I'm on a mac) so here's how I did it:

  1. Go to IntelliJ IDEA > Preferences > Editor > Live templates
  2. Click the + button on the top right, enter your template name and the following code:
// <editor-fold defaultstate="collapsed" desc="$DESCRIPTION$">
$SELECTION$$END$
// </editor-fold>
  1. In the description tab, enter "Code folding", click "Define" (next to "No applicable context yet") and select "Java" (or you can be more specific if you want), check the "Reformat according to style" checkbox and click Ok Now, if you select multiple lines of text in the editor, press
    ++T (CTRL+ALT+T in Windows) and select the "Code folding" template, enter a description and you're done.

Upvotes: 12

Nam G VU
Nam G VU

Reputation: 35374

It is now the default behavior in Netbeans 7.3.1.

Just select the lines and click Surround with ... as below snapshoot.

enter image description here

Upvotes: 20

kravemir
kravemir

Reputation: 10996

I've found it and it's simple :)

http://wiki.netbeans.org/SurroundWithCodeFolding

Upvotes: 11

Related Questions