Select, copy or cut the current line in Netbeans

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.


Solution 1:

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

Solution 2:

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.

Solution 3:

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.