geddski / macros

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

Feature Request: Control Structures #24

Open lrd1967 opened 6 years ago

lrd1967 commented 6 years ago

Is it possible to implement simple control structures to repeat a macro or a block inside a macro (or even a macro calling another macro) n-times or until end-of-line or end-of-file, for example?

dlidstrom commented 5 years ago

Or allow full access to JavaScript. I currently have these macros:

    "macros": {
        "keyboardScrollDown": [
            "cursorDown",
            {
                "command": "editorScroll",
                "args": {
                    "to": "down",
                    "by": "line",
                    "revealCursor": true
                }
            }
        ],
        "keyboardScrollUp": [
            "cursorUp",
            {
                "command": "editorScroll",
                "args": {
                    "to": "up",
                    "by": "line",
                    "revealCursor": true
                }
            }
        ]
    }

with keybindings:

    {
        "key": "ctrl+down",
        "command": "macros.keyboardScrollDown"
    },
    {
        "key": "ctrl+up",
        "command": "macros.keyboardScrollUp"
    }

I'd like to be able to run the "cursorUp" and "cursorDown" conditionally, only if the cursor moves outside the window (to keep it inside the window while ctrl-scrolling). That would allow me to emulate Visual Studio and Sublime behaviour.

If we had access to JavaScript that would solve your request and mine as well, provided we can query all editor properties.