geddski / macros

macros support for VS Code
MIT License
166 stars 36 forks source link

Copy a line and Paste it #36

Open tpitman opened 6 years ago

tpitman commented 6 years ago

I want to copy a line in a source code file, drop down 10 lines, highlight the line I end up at and paste the copied line over the top.

I am having trouble with the highlight a line and copy it and then the second highlight a line and paste over it.

Is there a forum for this extension that I can post this kind of question?

airandfingers commented 6 years ago

This seems to do what you want:

    "copyLine": [
        /* Highlight line */
        "cursorEnd",
        "cursorHomeSelect",
        /* Copy selection */
        "editor.action.clipboardCopyAction",
        /* Down 10 times */
        "cursorDown",
        "cursorDown",
        "cursorDown",
        "cursorDown",
        "cursorDown",
        "cursorDown",
        "cursorDown",
        "cursorDown",
        "cursorDown",
        "cursorDown",
        /* Highlight line */
        "cursorEnd",
        "cursorHomeSelect",
        /* Paste over selection */
        "editor.action.clipboardPasteAction"
    ]

Alternative approach:

    "copyLine2": [
        /* Copy current line to the line below, then move cursor down to it */
        "editor.action.copyLinesDownAction",
        /* Move line down 10 times (past target line) */
        "editor.action.moveLinesDownAction",
        "editor.action.moveLinesDownAction",
        "editor.action.moveLinesDownAction",
        "editor.action.moveLinesDownAction",
        "editor.action.moveLinesDownAction",
        "editor.action.moveLinesDownAction",
        "editor.action.moveLinesDownAction",
        "editor.action.moveLinesDownAction",
        "editor.action.moveLinesDownAction",
        "editor.action.moveLinesDownAction",
        /* Delete target line */
        "cursorUp",
        "editor.action.deleteLines"
    ]

Hope that helps :)

ctf0 commented 5 years ago

try https://marketplace.visualstudio.com/items?itemName=ctf0.macros