52

This is an IDE question

I am always working with collapsed methods, because I want to be able to see my methods all together. This is a little time consuming because I have to use the mouse to scroll up to the declaration of the method and click on the - (minus) icon. And then respectively go to the method I want to work on and click on the + (plus) icon.

Is there a way through a keyboard shortcut to do the collapse (and respectively the expand)?

Daniel Widdis
  • 8,424
  • 13
  • 41
  • 63
Stefanos Kargas
  • 10,547
  • 22
  • 76
  • 101

6 Answers6

126

I copied a piece from http://wiki.netbeans.org/KeymapProfileFor60.

The first option is for Win/Lin and the second for Mac.

Command Windows Mac
Collapse (hide) a block Ctrl + - + -
Expand a Collapsed Block (expand-fold) Ctrl + + + +
Collapse (hide) all code blocks Ctrl + Shift + - + Shift + -
Expand all code blocks (expand-all-folds) Ctrl + Shift + + + Shift + +

1 On Windows you can also use the numpad + and -
2 It says +, achkatually it's the = key

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
Peter Tillemans
  • 34,983
  • 11
  • 83
  • 114
10

Just to offer an alternative, have you considered using the Navigator View to navigate within the members instead? I usually just leave all methods uncollapsed, and double click on the method in the Navigator view to go to that method. What's nice about the Navigator View are the icons which provide visual indicators of the type and visibility of methods and fields.

JRL
  • 76,767
  • 18
  • 98
  • 146
4

Right click the window -> Code Folds -> Collapse All or Ctrl+Shift+Minus Sounds like what you ar looking for

Skatox
  • 4,237
  • 12
  • 42
  • 47
SirMedvind
  • 41
  • 1
3

The best workaround I've found sofar is to right-click in the white space next to the file tree and then click on "Collapse All"

AmanicA
  • 4,659
  • 1
  • 34
  • 49
1

To set default collapsing in netbean tool click Tools->Option->Editor->Folding, enable checkboxes

0

The navigator view does not show loop blocks, logic blocks, etc. So there is no way to collapse that section under the "if this" so you can focus on the "else that" section.

NetBeans only supports collapsing functions/methods (Java) or collapsing based on their XML formatted comment strings (a terrible solution that is IDE specific and leaves traces of your IDE all over your code).