Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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.

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.

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.

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

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

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

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.)

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top