geddski / macros

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

Type text where vscode has focus not just in the editor window #14

Open apillard opened 7 years ago

apillard commented 7 years ago

I am trying to create a macro that will execute a find and replace.

I can use editor.action.startFindReplaceAction but that just opens the input. I tried putting a command text after that to input the text I wanted to find but that typed the text in the main editor and not in the find dialog box. Is there anyway to pass arguments to find and replace or to have the type command add text to the input box instead of the editor?

BobSammers commented 7 years ago

+1 for this - search and replace is quite a major use case for me with macros.

Perhaps there is a complex command (i.e. one that takes parameters) that achieves this without needing to type in the search / replace boxes, but if so, I don't understand how to find it. The readme suggests looking in the keyboard shortcuts file for available commands, but doesn't say where commands with parameters (and the parameter names) can be found. Obviously, key bindings can only be used with commands that don't need parameters so the keybindings file either doesn't list them at all or doesn't give parameter names.

Is there a source listing complex commands?

martin-tarjanyi commented 7 years ago

I would like to write a macro to select a language (and format it according to that later). However, I'm not able to provide an input for this command automatically

"macros": {
        "json": [
            "workbench.action.editor.changeLanguageMode",
            {"command": "type", "args": {"text": "json"}},
            "list.select"
        ]
    }

This would be a very useful feature.

ghost commented 6 years ago

+1

ArturoDent commented 6 years ago

Complex commands:

https://code.visualstudio.com/docs/extensionAPI/vscode-api-commands

rsxdalv commented 6 years ago

This is caused by delay in the editor, to verify it you can add a bunch of write commands (and you'll see that they eventually write in the find window)

Solution: https://github.com/geddski/macros/pull/13