59
votes

In Netbeans I find keyboard shortcuts that deal with the current line of code very helpful, like:

  • Ctrl + Shift + : duplicate

  • Shift + Alt + : move

  • Ctrl + E : delete

Is there a shortcut for selecting, cutting or copying the current line of code? I've looked through many cheat sheets and thought I'll ask here before attempting a macro.

10

10 Answers

79
votes

Cutting current line: Ctrl + X
Selecting + copying current line: Ctrl + C
Yes, this actually works, but only when no current selection is active

12
votes

I found you could easily assign a keyboard shortcut for selecting the current line in the Keymap section of the Netbeans Options. I've now mapped Ctrl + . to do this.

10
votes

NetBeans supports editor macros.

  • Open a document.

  • Click in it to set an initial cursor position.

  • Click "Edit > Start Macro Recording".

  • Press Home, press Shift + End, press Ctrl + C.

  • Click "Edit > Stop Macro Recording".

  • You will now be prompted to name your macro. Use something obvious like select-entire-line.

  • Click OK

  • Click Set Shortcut... to assign a shortcut to the macro.

8
votes

In Netbeans 7.3, you can use Ctrl-Shift-Up or Ctrl-Shift-Down to duplicate the current line (the Up/Down determines where your cursor will be after the duplication). This is shown under the Source menu.

6
votes

Select any line endpoint and then just press
Ctrl+Shift+Down Arrow
together to duplicate the line.

5
votes

Triple click anywhere on that line. Then press Ctrl + C.

4
votes

alt + shift + arrow key (left or right, depending where your cursor is)

1
votes

I don't know if it's the case for Windows or Linux, but for example in the latest Netbeans IDE on Mac (v8.0) there is no default binding of the 'Select Line' shortcut. You have to manually specify it in Preferences -> Keymap -> Select Line.

The default binding for 'Delete Line', however, is ⌘-E (Command-E).

(I know this question is old and already answered, but just in case any other Mac Netbeans users come looking for the solution.)

0
votes

heh he. I've always used home, shift-end, ^C, since it works in just about every editor there is.

0
votes

On Netbeans 8.2, you can use

  • Ctrl + C : Shortcut "Copy"
  • Ctrl + Shift + V : Shortcut "Paste formated"

This will Copy/Paste the complete current line.