42

To duplicate lines I use

Ctrl + D

Is there a similar way to select/copy current line using keyboard in IntelliJ IDEA?

yalkris
  • 2,596
  • 5
  • 31
  • 51
  • A later duplicate of this Question, with more answers: [*Select current line in intellij*](https://stackoverflow.com/q/36572403/642706) – Basil Bourque May 11 '18 at 21:03

6 Answers6

69

If you have nothing selected, I think you can just hit CTRL-C to copy a line (or CTRL-X to cut it)...

http://grahamhackingscala.blogspot.co.uk/2010/08/fast-quick-line-cut-copy-intellij-idea.html

Hope this helps.

BretC
  • 4,141
  • 13
  • 22
  • 1
    I'm astonished even more than you, because this answer is completely useless, if you want to duplicate multiple lines (you'd use `ctrl`+`d`, but first you have to select many (how? I think they wanted `ctrl`+`w` to be used for this)) and it is the accepted and most voted answer in both places on SO asking this question (the second is [here](https://stackoverflow.com/questions/36572403/select-current-line-in-intellij)) – z33k Feb 23 '18 at 10:00
  • Ctrl+C is not copying the line in clion 2018.2. – vaibhav kumar Aug 23 '18 at 18:27
16

CTRL + X CTRL + V

CTRL + D - duplicate line CTRL + Y - delete line

5

In Mac OS ,i would like to keymap :

Command + D (Duplicate Line Or Selection) ==> Command + D (Duplicate Entire Lines)

This can duplicate a/multi line with the caret (insertion point) ,work in IntelliJ 2018.1.

enter image description here

or another way:

copy multiline with the caret (insertion point),not change keymapp, copy extra newline feed hidden "\n": enter image description here

LuciferJack
  • 781
  • 11
  • 12
2

CTRL + C selects the whole line. CTRL + D duplicates the selected line.

niktor
  • 71
  • 1
  • 5
  • 1
    Currently, only Ctrl + D (without selection) is enough to duplicate current line and it is the best option using the default shortcuts of multiples JetBrains IDE. If make a selection make sure to select the whole line, Ctrl + C is the shortcut for that, before hit Ctrl + D. The effect is the same as Alt + Shif + Down Arrow shortcut of VSCode. – Leandro Arruda Mar 10 '21 at 15:58
0

If you go to the specific line rather at the start or positioned at a specific row and column you can use the CTRL + W to select portions of the text depending on its complexity and language.

If you are at the start of the line and you want to select the entire text it's going to require to use CTRL + W 2 times, firstly it's going to select the first character and then the entire row till the end.

Philipos D.
  • 2,036
  • 1
  • 26
  • 33
0

I find a useful method, using Fn + ← or → to move to the beginning or end of the line, and using Fn + shift + ← or → to select a row.

Link_Chen
  • 1
  • 1