257

Anyone know the keyboard shortcut to copy/paste a line into a new line in Eclipse, without having to highlight the entire line?

ctrl-alt-down turns my whole screen upside down (I'm on windows). Interestingly, that's what's specified in the windows->preferences.

jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252
Prabhu
  • 12,995
  • 33
  • 127
  • 210
  • 6
    Eclipse doesn't have this. IntelliJ does it very well. Ctrl-C will copy the whole line if nothing is highlighted. Also Ctrl-D duplicates a line as it is Ctrl-Alt-Down in eclipse. – fastcodejava Feb 23 '10 at 21:50
  • 7
    Presumably flipping your screen upside down is not something you want to do often (unless you're a vampire/bat). Get rid of your graphics config and accept the best answer. – Stephen Feb 23 '10 at 21:55
  • 1
    @fastcodejava Many people praised IntelliJ, but they still use eclipse. Is it because eclipse is the requirement of a team? – Nick May 26 '14 at 01:34
  • 2
    Change Key preferences in Eclipse, assign some other shortcut "ctrl+alt+shit+down arrow" to "copy lines" action. – Akshay Lokur Mar 09 '17 at 03:35

26 Answers26

412

Ctrl-Alt-Down: copies current line or selected lines to below

Ctrl-Alt-Up:: copies current line or selected lines to above

Ctrl-Shift-L: brings up a List of shortcut keys

See Windows/Preference->General->Keys.

andrewrjones
  • 1,801
  • 21
  • 25
Pierre-Antoine LaFayette
  • 24,222
  • 8
  • 54
  • 58
  • 114
    That makes my whole screen upside down (I'm on windows). Interestingly, that's specified in the windows/preference – Prabhu Feb 23 '10 at 21:45
  • 100
    If you are using Intel HD Graphics, it's quite possible that these shortcuts are binded by Intel graphics util. You can disable hotkeys from notification area util -> Graphic Options -> Hot Keys -> Disable. After that I could use those useful shortcuts. – ilvez Feb 23 '13 at 17:55
  • put you may have to look at this http://superuser.com/questions/373832/disable-alt-arrow-display-flip – Mohammed Subhi Sheikh Quroush Mar 04 '13 at 17:14
  • Anything for deleting a whole line? – CodyBugstein May 29 '13 at 21:28
  • 1
    try searching for it, you'd find this: http://stackoverflow.com/questions/591172/delete-a-line-in-eclipse – Pierre-Antoine LaFayette May 31 '13 at 15:35
  • CTRL + SHIFT + L is bringing up "Quick Text Search" in STS – fIwJlxSzApHEZIl Aug 15 '13 at 23:09
  • 4
    @Imray - Ctrl + D will delete the whole line. – KrishPrabakar Oct 17 '13 at 07:05
  • 19
    In Ubuntu it does not work because CTRL+ALT+down and CTRL+ALT+up are already used (workspace switching). What you can do is to redefine 'copy lines' and 'duplicate lines' to other keys sequences. I have used CTRL+ALT+D for down and CTRL+ALT+U for up. It works perfectly. – Rudy Vissers Oct 20 '14 at 12:04
  • I use Intel Graphic Card, when press `Ctrl+Alt+up/down`, have problem. My screen will rotate 180 degrees :) In this case, I must **disable default Intel Graphic Card shortcut keys** . It's my tip. – Vy Do May 11 '15 at 03:23
  • I have assigned new keys for these functions to be inline with vi editor `Windows>Preferences>General>Keys` – Reddy May 14 '15 at 10:30
  • FWIW this does not appear to work when using a remote desktop either – John Sep 03 '15 at 20:53
  • 1
    @gopi1410 a better option is to simply ubuntu/unity "all settings / keyboard / shotcut / navigation" (at the list end) and remove (backspace) these keybings that I my case I never used and never will :). And also in CCSM http://askubuntu.com/a/70103/46437 – Aquarius Power Mar 12 '16 at 19:59
  • 1
    Mac users: Analogously use "Alt-Command" instead of "Ctrl-Shift". – gustafbstrom Feb 18 '17 at 13:00
  • Had the problem that the shortcut was still not working after i disabled Intel HD Graphics-Hotkeys. The solution was to kill igfxHK.exe as described here: https://stackoverflow.com/a/28650058/4870255 – Sebastian Ax Jun 25 '19 at 14:30
71

(Tested on Windows) [Per below comments, works as well in Ubuntu, IBM RTC 4 / RSA 9]

  1. In Eclipse, press Ctrl+Shift+L two times in succession (or Ctrl + 3 > type: Keys > Enter).
  2. In 'type filter text' (search) text box, type Copy Lines
  3. Select the filtered row, right click the 'Binding' field, and do Select All
  4. Press Ctrl+Shift+V
  5. Give OK

From now on, for any line you want to duplicate, just press Ctrl+Shift+V.

KrishPrabakar
  • 2,824
  • 2
  • 31
  • 44
29

You have to turn off the graphics hot keys that flip the screen. If you're on Windows, you need to right click on the Windows desktop and select "Graphics Properties..." (or something similar depending on your version of Windows). This will bring up a screen where you can manage graphics and display options, look for a place where you can disable hot keys, sometimes it's hidden under something like "Options and Support". Turn off the CTRL + ALT + and CTRL + ALT + hotkeys (alternatively you can just disable all graphics hot keys if you're not using them).

clav
  • 4,221
  • 30
  • 43
  • 2
    It works like charm. I am using Windows 7. To disable all I did is to Right click on the Windows desktop and select "Graphics Properties" ->Options. Then selected "Off" at the left side on the resulting screen. This disabled all hotkey combination. I think there is no way to disable only some them, its all or none. Anyway I didn't need them. – nanosoft Dec 13 '14 at 16:40
  • Yay! I didn't even had to restart Eclipse, just disabled the Intel HD Graphics shortcuts and ctrl-alt-down just started working. – metatron Dec 09 '18 at 11:21
17

If you want to copy a line to the clipboard you can also use the trick:

Ctrl-Alt-Down followed by Ctrl-X

The drawback is that the file where you copy the line from becomes dirty.

Renso Lohuis
  • 484
  • 4
  • 8
14
  1. Ctrl-D would delete a line
  2. Ctrl-Z would undo deletion, with highlithing entire line
  3. Ctrl-X/C cut or copy entire line

The advantage over Ctrl-Alt-Down followed by Ctrl-X suggested by other users is that it doesn't make eclipse think that the file was changed in any way. It's also faster and causes no problems even if the user has rotating screen issue with Ctrl-Alt-Down/Up keyboard shorcut. So there's no need to remap shorcuts for this.

Another way to go would be hitting Alt-Shift-Up until the entire line gets selected. If you've gone too far, of course you can select less with Alt-Shift-Down.

beam022
  • 1,793
  • 4
  • 20
  • 27
13

If Your Window pc, you may try this, it's also for STS:

Ctrl + win + Alt + Down :: Copy current line or selected line to below

Ctrl + win + Alt + Up :: Copy current line or selected line to above

Imranmadbar
  • 4,681
  • 3
  • 17
  • 30
11

I've written the linecopypaste plugin for Eclipse that mimics Visual Studio's copy/cut/paste behaviour. I've also found copycutcurrentline which appears to do the same.

larsch
  • 961
  • 8
  • 17
10

On my Mac the default setting is is ALT+CMD+Down

You can change/view all key bindings by going Eclipse -> Preferences (shortcut CMD+,) and then General -> Keys

Chris
  • 4,593
  • 1
  • 33
  • 37
7

Ctrl+Alt+Down Copies current line to below like notepad++ (Ctrl+D)

If your whole screen is 180° rotted then you should disable your hotkey settings.

Right Click -> Graphics Options -> Hot Keys -> Disable

enter image description here

That it now you done try shortcut Ctrl+Alt+Down

Community
  • 1
  • 1
Divyesh Kanzariya
  • 3,629
  • 3
  • 43
  • 44
5

Try this in MAC.

ALT + COMMAND + DOWN

it works.

Harsha
  • 818
  • 11
  • 10
4

If anyone using Mac computer the CTRL + ALT + DOWN keys doesn't work.

Try it with,

ALT + COMMAND + DOWN

It works.

Fabich
  • 2,768
  • 3
  • 30
  • 44
Harsha
  • 818
  • 11
  • 10
4

We can assign any command to any action(given) in Eclipse From Menu Bar go to Window > Preferences then search for the keys then search copy line then click on copy line and then click on command in Binding and peform a command which you wish to use for duplicating line i use ctrl+shift+d you can choose whatever you want enter image description here

Harvinder Singh
  • 1,919
  • 21
  • 15
3

I have to change the assigned key, e.g.

Windows/Preference --> General --> Keys

Select "Duplicate Lines" under command Click on "Binding" Ctrl + Shift + D

Abdullah Khan
  • 12,010
  • 6
  • 65
  • 78
Amit S
  • 151
  • 9
3

On Mac, I've tried the linecopypaste and it works great cmd+c -> Copy current (unselected) line, just like "yy" command in Vi/Vim cmd+v -> Paste it, like "p" command in Vi/Vim

Thank's Larsch for your work!

PD: Using Eclipse Luna 4.4.2 in Yosemite

Nicofisi
  • 1,083
  • 1
  • 15
  • 27
Aldo Bassanini
  • 475
  • 4
  • 16
2

Disabling the hot keys for the Intel Driver worked for me for Windows 7. However, for Windows 8, when I tried that, it prevented eclipse from getting the Ctrl-Alt-Down keystoke. I had to change the Intel driver key binding to Ctrl-Alt-F10 (or something else it will accept). Eclipse then gets the Ctrl-Alt-Down and copies the line.

Abdullah Khan
  • 12,010
  • 6
  • 65
  • 78
  • Maybe its not available in all versions, but looking at the Intel HD Graphics Control Panel there's also an option to "Disable" all shortcuts underneath the "Mange Hot Keys" section. I just disabled it all... (irritating that they force you to specify a key binding for everything when "Manage Hot Keys" is enabled) – dutoitns Jun 04 '17 at 05:29
2

Just another approach:

1) Alt+Up and Alt+Down (or Alt+Down and Alt+Up, order does not matter)
2) Ctrl+C

But of course vim's "yy" is the fastest :)

user1278890
  • 643
  • 8
  • 22
2

For mac, shift+alt+down_arrow works in netbeans' editor.

4b0
  • 21,981
  • 30
  • 95
  • 142
2

It's working with me on , Eclipse + Spring tool suite .

ALT + COMMAND + DOWN

Abd Abughazaleh
  • 4,615
  • 3
  • 44
  • 53
1

I am using Windows 7. To disable that all I did is to Right click on the Windows desktop and select "Graphics Properties" ->Options. Then selected "Off" at the left side on the resulting screen. This disabled all hotkey combination. I think there is no way to disable only some them, its all or none. Anyway I didn't need them. So now crtl+Alt+Up and Crtl+Alt+down works for me in Eclipse and my screen stays same :) I think similar option also exist in other versions of Windows. Have fun :)

nanosoft
  • 2,913
  • 4
  • 41
  • 61
0

To copy text from the begining of line to the cursor position: ctrl + insert

It does the job and save a lot of time for me.

Nicofisi
  • 1,083
  • 1
  • 15
  • 27
i474232898
  • 781
  • 14
  • 25
0

ctrl+alt+down/up/left/right takes precedence over eclipse settings as hot keys. As an alternative, I try different approach.

Step 1: Triple click the line you want to copy & press `Ctrl`-`C`(This will
select & copy that entire line along with the `new line`).
Step 2: Put your cursor at the starting of the line where you want to to paste
your copied line & press `Ctrl`-`V`.(This will paste that entire line & will
push previous existing line to the new line, which we wanted in the first place).
Fabich
  • 2,768
  • 3
  • 30
  • 44
being_ethereal
  • 795
  • 7
  • 26
0

The Ctrl+Alt+Down / Ctrl+Alt+Up flips my screen so I overrode that in the Eclipse shortcuts via Window => Preferences => General => Keys. Search for "dupl" to find the Duplicate Lines command. I overrode the default and chose Ctrl+Shift+D. For me, that's easy to remember just like Ctrl+D to delete lines

Fabich
  • 2,768
  • 3
  • 30
  • 44
gillian bc
  • 31
  • 2
0

For personal usage, I add a vim plugin like Vrapper to Eclipse and just use yy to copy entire line.

Eugene
  • 10,627
  • 5
  • 49
  • 67
0

The combination of Ctrl + Shift + Alt + Down worked for me on Linux.

Nicofisi
  • 1,083
  • 1
  • 15
  • 27
0

Another shortcut way to do this is press Ctrl+Shift+L and select which command you want to perform and hit enter enter image description here

its best practice for beginner.

Ramnath
  • 179
  • 9
0

See how to make the eclipse default shortcut work ctrl alt

  1. Select line: Put cursor on the line to copy, select line with ShiftHome if cursor in the end of line or ShiftEnd if cursor is in starting of line
  2. Duplicate line below (default expected behavior) or above ctrl alt or ctrl alt but the key here is you need to select the line/block

Some answers focus on disabling the screen Rotation in Windows or any other OS, that applies to prevent accidental keypress.

Paul Bradbury
  • 482
  • 6
  • 8