How to pass parameters to a build in Sublime Text 3?

后端 未结 2 2064
心在旅途
心在旅途 2021-02-04 13:39

I\'m currently making a program (which requires some arguments) that runs on the terminal.

Now I would like to run this same program from Sublime Text, but I don\'t kno

2条回答
  •  天涯浪人
    2021-02-04 14:14

    You can create a new build system for sublime text and run your script with fixed arguments.

    Create a new File in your Packages/User directory (CTRL-SHIFT-P --> "Browse Packages")

    New File: Packages/User/my_build.sublime-build

    with the following content:

    {
       "cmd": ["python", "$file", "arg1", "arg2"]
    }
    

    (replace arg1,arg2 by your arguments - you can delete them or add more if you want)

    Now restart sublime text and select your build system in the Menu: Tools --> Build System --> my_build. From now on, when you press CTRL-B your build system will be executed.

    Don't forget to change it back to "Automatic" if you are working on other files or projects.

    There are many options you can set in build files. Please refer to https://docs.sublimetext.io/guide/usage/build-systems.html

提交回复
热议问题