8

What is the shortcut to copy current line in VSCode?

I know we can Ctrl+L to select the line then Ctrl+C to copy. But is there any better solution. For example, in Geany, we can Ctrl+Shift+C to copy the line where the cursor is.

To be clear I am not talking about Duplicate line in Visual Studio Code

Ahmad Ismail
  • 11,636
  • 6
  • 52
  • 87

3 Answers3

30

Here is your solution for your problem

Just press the Ctrl + C without selection it'll copy entire line and you can past it wherever you wanted,

Please read below solution for the query you ask in your question's comment

Stackoverflow don't have the close option but you can delete the question from you profile or you can follow the explaination to mark your question closed from the below link:

How to Closed Questions on StackOverflow?

Bhargav Tailor
  • 442
  • 4
  • 8
16

Another alternative to the accepted answer that I often use is SHIFTALTDOWN which duplicates the current line to the line below (likewise, SHIFTALTUP duplicates to the line above). Once you get the copy of your line you can use ALTUP/ALTDOWN to move it wherever you want. This works well if you are wanting a copy of the line in the near vicinity of the current line.

AndyJ
  • 1,204
  • 3
  • 14
  • 28
2

Go to File ==> Preferences ==> Keyboard Shortcuts, and update the copy line shortcut entry with any combination you like.for example Ctrl + DownArrow is good for me.

enter image description here

Ahmad Ismail
  • 11,636
  • 6
  • 52
  • 87
Smichi
  • 23
  • 2
  • 1
    I have edited the question to show the image. However, this is a wrong answer. The question explicitly says "To be clear I am not talking about [Duplicate line in Visual Studio Code](https://stackoverflow.com/questions/38727047/duplicate-line-in-visual-studio-code)" – Ahmad Ismail Jan 18 '22 at 14:42
  • Thanks, i was in a hurry, it seems that i haven't read the rest of the post . – Smichi Jan 18 '22 at 19:11