Home > other >  Duplicate selected text to a new line VS code?
Duplicate selected text to a new line VS code?

Time:12-29

I already found that the "command": "editor.action.duplicateSelection" will duplicate the selection right next to it.

I want to duplicate the selected text to a new line. The selection may not be the entire line.

CodePudding user response:

If you are talking about a selection that is less than the entire line, there is no built-in way to duplicate selected text to the next line. It can be done with a macro extension which enables you to run multiple commands at once.

Using the macro extension copy selection down

Demo with adding static text to the duplicated text:

copy selection down with static text

CodePudding user response:

Click File > Preferences > Keyboard Shortcuts: Look for the Copy Line Down keyboard shortcut. enter image description here

  • Related