Although Geertjan Wielenga has been working with the NetBeans IDE and Platform for some time, he recently was introduced to a few NetBeans IDE Java shortcuts. He will be adding these to the NetBeans IDE Keyboard Shortcut Card, which can always be found under the "Help" menu in the IDE, for version 6.9. He decided to share his top 10 recently realized shortcuts in a blog entry. They are listed as follows:
FIRST SHORTCUT
Type "fcom" (without the quotes, same as all the rest below) and then press Tab. You now have this, i.e., a brand new code fold:
1.// <editor-fold defaultstate="collapsed" desc="comment">
2.// </editor-fold>
SECOND SHORTCUT
Type "bcom" and then press Tab to create the start of a new set of comments in your code:
1./**/
THIRD SHORTCUT
Type "runn" and press Tab and you'll have all of this:
1.Runnable runnable = new Runnable() {
2.
3. public void run() {
4.
5. }
6.};
FOURTH SHORTCUT
If I have this:
1.String something = "";
...and then below that type "forst" and press Tab, I now have this:
1.String something = "";
2.for (StringTokenizer stringTokenizer = new StringTokenizer(something); stringTokenizer.hasMoreTokens();) {
3. String token = stringTokenizer.nextToken();
4.
5.}
Also, experiment with "forc", "fore", "fori", "forl", and "forv"!
FIFTH SHORTCUT
I always knew that "sout" turns into "System.out.println("");" but did you know that (again assuming you first have a string something like above) if you type "soutv" you end up with this:
1.System.out.println("something = " + something);
SIXTH SHORTCUT
Next, here are the new shortcuts that will work only in 6.9:
* as - assert=true;
* su - super
* db - double
* sh - short
* na - native
* tr - transient
* vo - volatile
SEVENTH SHORTCUT
I knew that "ifelse" would resolve to an if/else block. But did you know that if you don't need an 'else', you can simply type "iff", press Tab, and then end up with this:
1.if (exp) {
2.
3.}
EIGHTH SHORTCUT
In 6.9, the "sw" shortcut expands to the following:
1.switch (var) {
2. case val:
3.
4. break;
5. default:
6. throw new AssertionError();
7.}
NINTH SHORTCUT
If you're using while loops, experiment with "whileit", "whilen", and "whilexp".
TENTH SHORTCUT
Always remember these: "im" expands to "implements; "ex" to "extends".
Note: to clarify the code listed in this article, visit Wielenga's original blog post.
More Information
Top 10 Interesting NetBeans IDE Java Shortcuts I Never Knew Existed Wielenga's blog entry
Developing Access Control Software on the NetBeans Platform
A Guide to Using NetBeans IDE with Kenai Projects
Details on NetBeans 6.8
[...read more...]