geddski / macros

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

Define a task to execute a macro #27

Open suzeeparker opened 6 years ago

suzeeparker commented 6 years ago

Is this possible, or is the only way to invoke a macro with a keystroke binding?

joshuatz commented 5 years ago

I realize a lot of time has passed since you asked this, but I just came across the same issue and wanted to answer this in case you or anyone else is still looking for it.

VS Code introduced running internal commands (vs shell commands or other types) in Dec 2018 (Github issue #11396). So you can now easily run any macro via a task, just by using the right syntax. Example tasks.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Format Indents",
            "type": "process",
            "command": "${command:macros.indentFormatter}",
            "problemMatcher": []
        }
    ]
}