Dec
9
2011

NetBeans Shortcuts ( Part I )

 Coding for the best of us is a long tedious and frustrating process. Yes at times it can be all exhilarating when we get stuff right but there are moments when we feel like throwing our laptop through the window. An IDE or an Integrated Development Environment makes coding a whole lot easier and yes prevents the guy down on the street from getting hit by a laptop. NetBeans is a powerful IDE and is my personal favorite. It is easy to use and conveniently supports multiple languages and platforms. In this series of stones dedicated in making your experience in NetBeans and coding in general fun, I will be talking about the various shortcuts the guys at NetBeans have developed for us to use.

I will tell you about all the various Navigational shortcuts NetBeans has to offer. So let’s get started:

Switch between documents:

When you have multiple documents open at the same time, press Ctrl-Tab, and then a small popup appears. You can scroll through the popup, which displays all the open documents, and then choose the document that you want to open:


Goto Decleration:

When you need to quickly get to a declaration of any given variable just press Ctrl-B. Netbeans will take the caret to the line containing the declaration of the variable.


Goto Line:

To quickly get to any given line press Ctrl-G and a dialogue box will pop up asking you which line should it take you to. This is particularly useful when trying to detect errors.


Bookmarks: 

When you press Ctrl-Shift-M, the current line is “bookmarked”. What this means is that you can later quickly cycle back/forward to it (with Ctrl-Shift-Period and Ctrl-Shift-Comma). The bookmarked line gets a small icon in the left sidebar, as shown below, until you press Ctrl-Shift-M on the line again, to remove the bookmark:


Selecting in Projects/Files/Favourites :

To quickly select in the projects tab press CTRL-SHIFT-1/2/3 and the projects window/File window/ Favorite window will open up for you to browse through and select the desired item.


Move Caret to matching bracket:

 To get the caret to the matching bracket press Ctrl-C. This shortcut is very useful when you are dealing with multiple loops.


Move to last edit:

To get the caret to the last point where you edited press Ctrl-Q. This is particularly useful when you find yourself in a situation where you have edited in one document, while you currently find yourself in a completely different document.


Marked occurrence:

To quickly find the various occurrences in the code of any marked object press Alt-Up/Down. This is very useful when dealing with a large code segment and you need to locate all the usages of a given variable.


Find usages:

To find usage of any given method or a field, just get the caret to that field or method and press Alt-F7. Netbeans will show you all the usages of the given method or a field within the project.


Capture inner/outer syntactic element: 

Each time you press Alt-Shift-Period, the selection expands to a successively wider syntactic element. For example, below one statement was selected, the key combination Alt-Shift-Period was pressed, and then the complete content of the surrounding block statement was shown to be selected. The selection expands from the current statement to surrounding block statements to the surrounding method and, from there, to the surrounding class and further. To successively narrow the selection, press Alt-Shift-Comma, instead of Alt-Shift-Period.


Subscribe to fortystones.
Follow @fortystones on Twitter.
Get updated from our Facebook Fanpage.

Share

Related Posts

About the Author: Prerak Pradhan

An IT student, primarily interested in Web development, Graphic Design and Animation.

1 Comment + Add Comment

  • I often use ctrl-shift-down, which duplicates a line of code.
    ctrl-up/down can be used to scroll without touching the mouse, also.

Leave a comment

*