3
votes

I'm tried each of the following keybindings.json ctrl+enter "command" settings to enable execution of two commands when the .py[thon] script editor extension is active. The single commands work but none of the attempts to associate multiple commands or a macros reference containing multiple commands, work. The later generates a "command 'macros.<macro defined in settings.json>' not found."

Any pointers on how I get multiple commands attached to a single keyboard shortcut definition, specifically what's wrong with how i'm setting up macros approach?

// %appdata%\Code\User\keybindings.json
[    
    {
        "key": "ctrl+enter",
        //"command": "python.execSelectionInTerminal",
        //"command": "cursorDown",
        //"command": [ "python.execSelectionInTerminal", "cursorDown" ],
        //"command": "python.execSelectionInTerminal, cursorDown",
        //"command": "python.execSelectionInTerminal && cursorDown",
        "command": "macros.pythonExecuteLineAndMoveToNextOne",
        "when": "editorTextFocus && editorLangId == 'python'"
    }
]

// %appdata%\Code\User\settings.json
{   
    "macros": {
        "pythonExecuteLineAndMoveToNextOne": [
            "python.execSelectionInTerminal", 
            "cursorDown" 
        ]
    },
    .
    . .
    . . .
}
1
Your macro looks correct to me. You should try a different binding than ctrl+enter given how common it is. Or disable the "Insert Line Below" command which uses the same keys and editorTextFocus and may conflict.Mark
@Mark thanks for response. The ctrl+enter keybindings associating works fine if I only specify a single command. Its my efforts to wire it up to multiple commands, specifically through use of a macros setting that isn't working. Not following what you mean by "disable the 'Insert Line Below' command" statement as I only have a cursor down command no insert line command defined.myusrn
You do have the macros extension installed?Mark
I did not as the article I found outlining use of it didn't comment on needing the "macros" extension by publisher:"geddski" installed. I added it and now things are working, thanks.myusrn
Add and accept an answer so this question does not appear in lists of unanswered questions.Scott McPeak

1 Answers

0
votes

Adding duplicate of answer raised in comments so it can be accepted to change state of this question to answered.

The fix was to add the @name:macros @publisher:geddski vscode extension which was mentioned in the article i used to arrive at the multi-step macro definitions. It wasn't initially clear that it was a requirement.