EN
VS Code - duplicate current line
7
points
In this short article, we would like to show how to duplicate / copy the current line in VS Code.
Quick solution:
Windows:
Shift
+Alt
+↓
keysmacOS:
Shift
+Option
+↓
keysUbuntu:
Ctrl
+Shift
+Alt
+↓
keys
Practical example
Simple steps:
- put caret to line that you want to copy,
- use one keys combination from the below table,
Depending on the operating system:Keys combination Description OS Shift
+Alt
+↑
Shift
+Alt
+↓
Shift
+Alt
+Up
/Down
on Windows
↑
arrow - copy to up↓
arrow - copy to downWindows
Shift
+Option
+↑
Shift
+Option
+↓
Shift
+Option
+Up
/Down
on macOS
↑
arrow - copy to up↓
arrow - copy to downmacOS
OS X
Ctrl
+Shift
+Alt
+↑
Ctrl
+Shift
+Alt
+↓
Ctrl
+Shift
+Alt
+Up
/Down
on Ubuntu
↑
arrow - copy to up↓
arrow - copy to downIt may be not working if some default configurations override keys.
Ubuntu
- the line should be duplicated
Using VS Code menu
It is possible to make a line copy from the options menu in VS Code.
Simple steps:
- put caret to line that you want to copy,
- go to VS Code menu and use:
Selection -> Copy Line Up
or
Selection -> Copy Line Down - the line should be duplicated
Screenshot: