Do you know that shortcuts help you accelerate your development productivity? Indeed, the more time you use keyboards, the higher efficiency you get. Therefore today I’m going to share with you the common shortcut keys which are designed for editing code in NetBeans IDE.

NOTE: Standard shortcuts are not covered, such as Ctrl + Space (auto-complete), Ctrl + A (select all), Ctrl + Z (undo), and the like.

 

  1. Ctrl + E or Shift + Delete: deletes the current line.  

  2. Ctrl + Delete: deletes the next word after the cursor. If it is a compound (i.e. using camel case like fileHandler), then only the first word is deleted.  

  3. Ctrl + Backspace: deletes the previous word before the cursor.  

  4. Alt + Shift + Up: Moves up the current line (or a selected block of code) by one line:  

    Move up a line

     

  5. Alt + Shift + Down: Moves down the current line (or a selected block of code) by one line:


     

    Move down a line

     

  6. Ctrl + Shift + Up: Copies and moves up the current line (or a selected block of code) by one line:  

    Copy and move up

     

  7. Ctrl + Shift + Down: Copies and moves down the current line (or a selected block of code) by one line:  

    Copy and move down

     

  8. Shift + Enter: Inserts a blank line below the current line, regardless of position of the cursor in the current line (it’s very different than pressing Enter key alone):  

    Insert new line after current line

     

  9. Ctrl + Enter: Works similar to Shift + Enter, but insert a blank line above the current line if the cursor is at the beginning of line.  

  10. Ctrl + Shift + I: Organizes import statements by removing unused imports and adding missing ones:  

    fix import statements

     

  11. Alt + Shift + F: Formats a selected block of code or the whole source if no block is selected.  

    format code

     

  12. Ctrl + Shift + C or Ctrl + /: Toggles comment for the current line or a selected block of code:  

    toggle comment

     

  13. Alt + Insert: Shows context menu to generate code e.g. insert constructor, getters and setters. The list of commands in the menu is depending on the surrounding code:  

    generate code

     

  14. Ctrl + F12: Inspects members of a class. This opens and activates the Navigator window:  

    inspect members

     

  15. Alt + F12: Inspects hierarchy of a class. This opens and activates the Hierarchy window:  

    inspect hierarchy

     

  16. Ctrl + Shift + Enter: Toggles maximize/minimize the current code editor.
 

Other NetBeans Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.



Add comment

   


Comments 

#10Codo2023-01-24 10:59
Quoting OAtuh:
Do you know how to disable "one line" copy when nothing is highlighted?


I couldn't live without Ditto, my favorite clipboard Manager. It saves a copy of everything I copy. To paste, I don't do Ctrl + V --> I do Alt + V and then Ditto appears and shows all the last copied clips. Nothing is lost as long as you copy it. Anyway, Windows already includes another clipboard manager that you can access with Win key + V. I prefer Ditto, though.
Quote
#9Holly Hooper2021-11-11 05:01
I аm curious tօ find out what blog platform you Һappen tߋ be սsing? I’m havіng some small security issues ѡith my latest website and ӏ’ԁ likе to find sߋmething mоre secure. Do you Һave any recommendations?
Holly Hooper
Quote
#8Mimi2021-06-28 08:53
Great job! I have a question. Is there a shortcut to remove unused variables in netbeans (like we can do in eclipse) ? thanks
Quote
#7Harold Burton2021-06-07 11:31
Nowadays with enough time and patience, most any game can be waded through."" HE SAID WHILE RUNNING A DARK SOULS CLIP. That had to be intentional trolling, right? Telling people who can't beat Souls games that they suck and just need to ""git gud""?EDIT: actually now that I look again it's that samurai Souls clone from Koei-Tecmo. Oh well. I haven't played it yet, but I'm guessing they copied the dificulty along with everything else, so the point still stands.

Harold Burton
Quote
#6OAtuh2020-10-18 11:22
Do you know how to disable "one line" copy when nothing is highlighted?

This feature is really annoying to me. Especially when I want to paste the text I have copied, I often hit the wrong shortcut (I hit ctrl+c instead of ctrl+v). So the text in my clipboard is replaced by the text at that line (one line).
It's annoying because I have to get back to the original text and do the process again.
I hope someone can help me.

Thank you!
Quote