Select, copy or cut the current line in Netbeans
NetbeansKeyboard ShortcutsNetbeans Problem Overview
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.
Netbeans Solutions
Solution 1 - Netbeans
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 - Netbeans
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
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.
Solution 4 - Netbeans
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.
Solution 5 - Netbeans
Select any line endpoint and then just press
Ctrl+Shift+Down Arrow
together to duplicate the line.
Solution 6 - Netbeans
Triple click anywhere on that line. Then press Ctrl + C.
Solution 7 - Netbeans
alt + shift + arrow key (left or right, depending where your cursor is)
Solution 8 - Netbeans
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.)
Solution 9 - Netbeans
heh he. I've always used home, shift-end, ^C, since it works in just about every editor there is.
Solution 10 - Netbeans
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.