macros icon indicating copy to clipboard operation
macros copied to clipboard

Copy a line and Paste it

Open tpitman opened this issue 6 years ago • 2 comments

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?

tpitman avatar Jun 06 '18 14:06 tpitman

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 :)

airandfingers avatar Jun 28 '18 08:06 airandfingers

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

ctf0 avatar May 11 '19 15:05 ctf0