yodalr
yodalr

Reputation: 10942

Visual Studio Code - duplicate selection ONLY

There is a solution on how to duplicate a line. But how do I duplicate the selection? Like in Notepad++.

Upvotes: 8

Views: 3312

Answers (2)

VonC
VonC

Reputation: 1329692

There is now a dedicated command, with VSCode 1.40 (Oct. 2019):

Duplicate selection

We have added a new action named Duplicate Selection.

  • When executed, the current selection will be duplicated and the result will be selected.
  • When there is no selection, the current line will be duplicated, all without writing to the system clipboard.

You can associate a keyboard shortcut to that command.

Upvotes: 3

Eric Constantinides
Eric Constantinides

Reputation: 146

This extension worked for me:

https://marketplace.visualstudio.com/items?itemName=lafe.contextualduplicate

I then opened up my Keyboard Shortcuts to assign a memorable binding. In my case, I used <SHIFT><COMMAND>-D so it behaves just like Sublime Text.

Upvotes: 6

Related Questions