Friday, April 18, 2008

Top 10 NetBeans IDE Keyboard Shortcuts I use the most

Initially for exploration of the features working with mouse may feel fancy but as you continue using the tool for project development and want to concentrate more on task in hand you start finding ways to do things faster. NetBeans IDE 6.1 provides many keyboard shortcuts if used judiciously they can save a lot of developers time.

I use certain shortcut keys more often than other keys. This is a list of the keyboard shortcuts for NetBeans IDE which I use in my day to day development tasks.

1. CTRL+F12 Navigate to Member

When my class becomes big and there are many methods in the class navigating to a specific method becomes easy with this dialog box.

As soon as I start typing the name of the desired method the dialog contents are filtered for me to select from matching method names starting from what I have typed.


2. SHIFT+ESC Toggle Editor Maximize / Minimize

I like working in the fully maximized editor window. SHIFT+ESC maximize the editor window for me and I can work with full concentration. When I need to see other windows I can again press SHIFT+ESC and I get the normal layout of windows back.


3. CTRL+7 Activate Navigator Window

When I am in maximized editor mode and I need to navigate to some method, either I choose the method 1 as described above or sometimes I use CTRL+7 to activate the navigator window. The windows other than editor in NetBeans follow a specific pattern, you can type characters and a quick search window appears which selects the most appropriate item from the window according to what is typed in this quick search window.


4. CTRL+/ Toggle Comment

For quick commenting of some lines I select those lines and press CTRL+/ to comment all those selected lines. The same lines can be uncommented again by following the same process.


5. ALT+SHIFT+F Format Code

This key combination formats my code to the standard Java Code Formatting template.

6. CTRL+0 Activate the Editor

When I am in the Navigator window through the shortcut CTRL+7 and I want to navigate back to the editor i press CTRL+0. I do not need mouse to do this navigation and save a lot of time in navigating between windows.

7. CTRL+# Activate different windows

These shortcuts are handy for navigating between the different windows. They become very important when I work in maximized editor mode.
CTRL+1 - Project Window
CTRL+2 - Files Window
CTRL+3 - Favorite Window
CTRL+4 - Output Window
CTRL+5 - Services window
CTRL+6 - Tasks Window

8. ALT+INSERT Generate Code

When I need to generate getter setters or constructors this key combination brings the Code Generation menu


9. ALT+F7 Find Usages

Many a times I want to track all the occurrences of a particular method call. Who is calling my method. This Find Usages dialog comes handy in such times.


10. CTRL+F4 Close Editor Window and CTRL+SHIFT+F4 Close All Editor Windows

I use these keys often to close my editor windows and save many mouse clicks.

with regards
Tushar Joshi, Nagpur

39 comments:

  1. My absolute favourite shortcut is Strg+Shift+V = Paste formatted.
    This shortcut is a small macro for "Strg+V (Paste), Select, Alt+Shift+F (Format)

    very usefull :-)

    best regards, josch.

    ReplyDelete
  2. Thanks Josch for adding your favorite shortcut. Let other readers also add their favorite shortcuts in comments and this will be a list of most favorite shortcuts in NetBeans IDE

    with regards
    Tushar

    ReplyDelete
  3. I think shortcut Shift+Ctrl+I is very useful. It will save your time when you have to put more then one import to your file.

    ReplyDelete
  4. Thanks Michalch,

    In my case I seldom use this shortcut because I follow the habit of getting the code auto-completed from NetBeans. NetBeans adds the import automatically when we auto-complete the elements. Yes but this shortcut is handy to use when you copy paste some code in your file and now want to organize all the imports.

    with regards
    Tushar

    ReplyDelete
  5. Yes - that's right. But in my opinion, auto-complete is quite often too slow, so I mostly just write the code and then I use the auto-import shortcut.

    ReplyDelete
  6. Sorry. Fix-import shortcut. :)

    ReplyDelete
  7. I really like Ctrl+Shift+arrow down very usefull when you need duplicate line.

    ReplyDelete
  8. I like ALT-F4, means you can go home...

    ReplyDelete
  9. >> I think shortcut Shift+Ctrl+I is very useful.It will save your time when you have to put more then one import to your file.

    And if you have to remove some imports

    >> I like ALT-F4, means you can go home...

    But I use NB @ home ;-)


    My favourites are:
    Close Window with CTRL+W (easy) instead CTRL+F4 (impossible)
    Change Window with CTRL+PageUp or PageDown (even works in firefox)
    Refactor with CTRL+R
    QuickFix with ALT ENTER
    Open Context Menu SHIFT+F10

    And of course CTRL+Space ;-)

    Maybe someone needs more:
    http://wiki.netbeans.org/KeymapProfileFor60

    ReplyDelete
  10. Any way to re-assign a shortcut key? I like Ctrl+Space for auto-completion, but on some machines, that's reserved for switching between languages.
    Thanks!

    ReplyDelete
  11. Tools -> Options -> Keymap - you can edit virtually any mapping, I suppose, just have to find the right one ;>

    ReplyDelete
  12. Does anyone knows wich one is the shortcut to increase font size???

    I enjoy reading a decent font (I mean medium-big) while I code, but sometimes I need to make a ZOOM out to see the structure, so changing the size in the options is a pain in the ass.........Is there any shortcut to make it easily while we are editing?

    Thanks in advance

    ReplyDelete
  13. I like the the quick like copy shortcut.
    1. point to the line you want to copy, (or select multiple lines) and
    2. CTRL + SHIFT + Down Arrow Key

    ReplyDelete
  14. One thing I miss is fast navigation to next or previous member (method, field, etc.) with the keyboard, like ctrl-alt-up arrow and ctrl-alt-down arrow. I think it's not possible with netbeans or is it ?

    ReplyDelete
  15. CONTOL + SPACE instead of typing "this." then alt enter... then delete the "this." is slow when you forget a method name lol...
    ALT + ENTER is uber awesome when you are in middle of looping classes like GroupLayoutGroups

    ~Sonis

    ReplyDelete
  16. Oh and Holding Control Left clicking on methods is much faster to look over API instead of trying to load the javaDocs on new things :)

    ReplyDelete
  17. Another great article about shortcuts based on this one is CTRL+; (ctrl and semicolon) which adds a semicolon to the line. Very useful. For Php it doesn't work but you can use macros to set up the same thing.

    Great other article about shortcuts based on this one (including macro details): http://www.phpmag.ru/2009/01/23/extremely-usefull-netbeans-shortcuts/

    ReplyDelete
  18. I remember using some shortcut for generating template for the likes of "for (i=0; blah blah)" and "if else.." but am unable to locate it now. poor memory, poor memory !
    Does anyone remember the shortcut ?

    thanks,

    PS: btw, I'm a vim supporter ;)

    ReplyDelete
  19. Muy bueno! hace rato lo andaba buscando, felicitaciones,
    Saludos.

    ReplyDelete
  20. @texens
    Tools->Options->Editor->Code Templates will show what you have forgotten.
    But I'll list the ones you mentioned here:
    fore + TAB:
    foreach ($cssclass as $value) {

    }
    forek + TAB:
    foreach ($cssclass as $key => $value) {

    }
    if + TAB:
    if (true) {

    }
    elif + TAB:
    elseif (true) {

    }
    els + TAB:
    else {

    }

    ReplyDelete
  21. Thanks to all NetBeans developers and enthusiasts for adding favorite key board shortcuts to this list.

    with regards
    Tushar

    ReplyDelete
  22. Hi

    Is there a shortcut which lets you find/open any file in the project? Like Ctrl+Shift+R or Ctrl+Shift+H (for Java types).

    Thanks
    Abhishek

    ReplyDelete
  23. Can any one tell me command or shortcut key which will check flow of code in NB6?

    Thanks,
    Avni

    ReplyDelete
  24. I've mapped the switching between tabs to (got to preferences -> keymap)
    Alt+Meta+Left
    Alt+Meta+Right

    This is on a Mac and the Meta key is the Apple key. This now corresponds to most other Mac application where you switch between tabs.

    ReplyDelete
  25. @Abhishek: Is there a shortcut which lets you find/open any file in the project? Like Ctrl+Shift+R or Ctrl+Shift+H (for Java types).

    => Use Alt+Shift+O in Netbeans 6.9

    ReplyDelete
  26. Alt+Shift+O is not woring for me; I'm using NetBeans 6.9.1. Any clues?

    ReplyDelete
  27. Can any one tell me how to check flow of code in netbeans.

    ReplyDelete
  28. Hi Tushar,

    Can you please tell me what is the short cut for "organize imports".

    or please share how to configure short-cuts

    Thanks,
    vidhya

    ReplyDelete
  29. Really this blogs helps me. Thank you...

    ReplyDelete
  30. ctrl + shift + arrow down.. v nice to copy line below ..

    ReplyDelete
  31. ctrl + shift + ; is the most useful when you want to add ";" at the end of the line while you are currently not there yet.

    ReplyDelete
  32. CTRL+SHIFT+D to copy 1 on the latest 9 text copied to the clipboard. Very nice ;)

    ReplyDelete
  33. Alt+Scrollwheel to magnify the editor window.

    ReplyDelete
  34. Ctrl+[ To toggle between open/closing tags.
    Ctrl+Sh+[ To (almost) select the text. Note that you will need to shift-select additional characters to include the enclosing tags.

    ReplyDelete
  35. Alt + shift + f to auto formation of your code..
    it will design your code hirarchy structural and it is very useful & time saving sortcut and functionality providing by NetBeans..

    ReplyDelete