適当なマクロエクステンションをインストールする
https://marketplace.visualstudio.com/items?itemName=geddski.macros
settings.jsonにマクロを設定する
"macros":{
"redirectTextFileAndRunPython":[
"workbench.action.files.save",
{
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "python app.py < input.txt\n" }
},
],
},
keybindings.jsonにマクロ名を記述する
{
"key":"ctrl+q",
"command":"macros.redirectTextFileAndRunPython"
}
追記
エクステンションなど入れなくてもkeybindできました!お恥ずかしい!
これだけ!
{
"key":"ctrl+q",
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "python app.py < input.txt\n"}
}