LoginSignup
0
1

More than 3 years have passed since last update.

vscodeでpythonを保存時に実行するマクロを使う

Last updated at Posted at 2020-01-28

適当なマクロエクステンションをインストールする
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"}
    }
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1