skip to Main Content

I know there’s a shortcut to duplicate a selected text:

To Copy Up – shift+alt+up

To Copy Down – shift+alt+down

But how can I do if I need to duplicate it, say, 33 times? Is there a faster way to do that?

3

Answers


  1. Unfortunately, as far as I know, Visual Studio Code does not provide built-in functionality to automatically duplicate code a certain number of times.

    Login or Signup to reply.
  2. If you know you might have to do this often, you could make a code-snippet for this. Maybe one that copies 10 rows at a time.

    {
        "Duplicate 10 lines of code at once": {
        "prefix": "dup",
        "body": [
            "$1",
            "$1",
            "$1",
            "$1",
            "$1",
            "$1",
            "$1",
            "$1",
            "$1",
            "$1"
        ],
        "description": "Copy the code, type "dup", then paste 10 lines of code at once."
    }
    
    Login or Signup to reply.
  3. A fairly fast way to achieve this is to create your 33 (or however many) lines in your editor, then use the multi-line cursor (hold Alt + Shift then use your mouse to select the lines you want the cursor to include), and then paste your text, like so:

    paste lots of lines using multi-cursor

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search