Select, copy or cut the current line in Netbeans

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


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.


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.


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.