Skip to main content

NetBeans Shortcuts

Code Editor-Related Shortcuts
  • Ctrl+Shift+Up – copy line under cursor up.
  • Ctrl+Shift+Down – copy line under cursor down.
  • Alt+Shift+Up – move line under cursor  up.
  • Alt+Shift+Down – move line under cursor  down.
  • Alt+Shift+Period – this one is used for selection, every time you press this one the selection widens to capture the next logical syntactic element. For example if you have your cursor over a word, pressing this ones would select the whole word, pressing again would select the whole line. If you’re inside a method definition, pressing it again would select the content of the method (between def ... end), once more would select the whole method. If you continue pressing it, you will eventually select the whole file. Very handy.
  • Alt+Shift+Comma – this one is the opposite of the one above, it will narrow the selection every time you press it.

  • Ctrl+/ – comment or uncomment line.
  • Ctrl+R – in-place rename entity under cursor. If it is a class, it will take you to the refactor dialog box. If it is a variable it will highlight all usages of that variable and attempt to change all of them to your new value (i.e. it is basically a rename refactor).
  • Ctrl+Q – go to last edited document/position. This will jump you to the last position you were editing before your current edit. If you were editing a different document before, it will jump you to that one. Keep pressing it to jump between positions you’ve been editing.
  • Ctrl+Shift+M – bookmark current line. This one is difficult to get used to, but if you want to remember a particular place for some reason, this is a handy one to know.
  • Ctrl+Shift+Period – cycle forward through bookmarks. Complements the one above.
  • Ctrl+Shift+Comma – cycle backwards through bookmarks. Complements the two above.
  • Alt+Enter – select quick fix. When the little light bulb appears offering a quick fix for a problem, you can use this one instead of clicking on it if your cursor is on the line.
  • Ctrl+B – go to declaration of symbol under caret. If it is a variable will jump to the first time the variable was declared. If it is a method name (i.e. method call) will jump to the definition of the method.
  • Alt+Shift+F – format code selection or file. If there is a selection, will format the selection, otherwise the whole file.
  • Ctrl+G – go to line. Will let you jump to a particular line number.
  • Ctrl+E – delete line under cursor. I love the ability to do this in Eclipse, so a really handy one to remember for NetBeans.
  • Ctrl+K – complete word by inserting word from buffer. This one is awesome! Start typing a word then press the shortcut – it will attempt to complete the word based on what else is currently in the file. If you press it repeatedly, it will cycle through all possible words in the file that might complete what you started typing. It does this very simply by scanning backwards through the file from your current position. It is usually correct the first time. Considering that IntelliSense is almost useless for Ruby development, this one is especially handy.
  • Ctrl+[ – jump to matching. This one is probably more useful for a language with brackets, but it can still be handy for Ruby to find a matching end for a do or an if.
  • Ctrl + Home – move cursor to start of file.
  • Ctrl + End – move cursor to end of file.
  • Alt + Shift + Right – move line one tab to the right. You can indent a line without having to move the cursor to the start of it.
  • Alt + Shift + Left – move line one tab to the left. Same as the one above, but lets you un-indent.
  • Shift + Enter – start new line below the current line and jump the cursor to the new line. Surprisingly handy.
  • do+Tab – insert do...end block. You just need to type do and then press TAB.
  • if+Tab – insert if...end block. Once again just type if and press TAB
  • ife+Tab – insert if...else...end block. Same story, type ife and press TAB.
IDE Related Shortcuts
  • Ctrl+Tab – scroll down through open files. If you have many files open in the IDE, this is a handy one to know. Pressing it once will pick the last open file you were in before the current one, keep pressing to scroll down through all the files currently open in the IDE.
  • Ctrl+Shift+Tab – scroll up through open files. The same as the one above but will let you scroll up through all the open files rather than scrolling down.
  • Ctrl+Shift+T – jump between tested file and test file. This one can be a little flaky but does work most of the time. If it doesn’t work for you, use one of the next two instead.
  • Ctrl+O – open a particular type. Search for a class by class name rather than file name.
  • Alt+Shift+O – open file by name. This one is complementary to the one above and will let you open a file rather than a type. Note that it is extremely slow if you have a large project (or several projects).
  • Ctrl+Shift+1 – select currently edited file in project view. I was so happy when I found this one, can be really annoying not to be able to jump to the file you’re editing (in project view).
  • Ctrl+Shift+2 – select currently edited file in files view. The brother of the one above, but lets you select the currently edited file in file view as opposed to project view.

If you have any other NetBeans shortcuts that would be particularly useful for Ruby development (i.e. I don’t just want any random ones, I know NetBeans has lots), please share and I’ll add them to the list.

Update: Here are some more handy shortcuts from the comments below (thanks to all the readers who shared their favorite ones)

  • Ctrl+1 – jump to files in project view
  • Ctrl+0 – jump back to editor (complements the one above)
  • Ctrl+Shift+V – pastes the code and formats it at the same time (very handy)
  • Ctrl+Shift+P – reformats/wraps comment lines to the designated right margin
  • Alt+Shift+F6 – run current test under cursor