Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NetBeans shortcut key for collapsing/expanding a method

JAVA - NETBEANS

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)?

like image 328
Stefanos Kargas Avatar asked Jun 03 '10 10:06

Stefanos Kargas


People also ask

How do I collapse code in NetBeans?

As shown in the servlet example and as described in Custom Code Folding in NetBeans, one can add custom code folding in NetBeans simply be enclosing the code to be folded within // <editor-fold> and // </editor-fold> comments.

How do I create a shortcut key in NetBeans?

Editing and Refactoring Code in NetBeans To add a keyboard shortcut for a command: Choose Tools | Options and click the Keymap panel. In the Actions panel, navigate to a command that you want to change, and click Add. In the Add Shortcut dialog box, type in the key combination that you want to use and click OK.


2 Answers

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

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

Collapse (hide) a block                     Ctrl + Minus                 Cmd + Minus Collapse (hide) a block                     Ctrl + NumPad Minus      Collapse (hide) all code blocks             Ctrl + Shift + NumPad Minus  Cmd + Shift + Minus Expand a Collapsed Block (expand-fold)      Ctrl + Plus                  Cmd + Plus Expand a Collapsed Block (expand-fold)      Ctrl + NumPad Plus   Expand a Collapsed Block (expand-fold)      Ctrl + Equals                Cmd + Equals Expand all code blocks (expand-all-folds)   Ctrl + Shift + NumPad Plus   Expand all code blocks (expand-all-folds)   Ctrl + Shift + Plus          Cmd + Shift + Plus Expand all code blocks (expand-all-folds)   Ctrl + Shift + Equals        Cmd + Shift + Equals  
like image 163
Peter Tillemans Avatar answered Sep 23 '22 09:09

Peter Tillemans


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.

like image 21
JRL Avatar answered Sep 22 '22 09:09

JRL