第一步:创建插件文件 runProject.py
import sublime
import sublime_plugin
import os
class RunProject(sublime_plugin.TextCommand):
def run(self, edit):
os.system("start /D D:\\project\\test test.exe")
第二步:打开Key Bindings添加如下json
{"keys":["f2"],"command":"run_project"},
第三步:按f2执行程序 test.exe
补充:
关于传参
{"keys":["f2"],"command":"run_project","args":{"ver":"project"}},
{"keys":["f3"],"command":"run_project","args":{"ver":"0.1.60.0"}},
代码可改为:
import sublime
import sublime_plugin
import os
class RunProject(sublime_plugin.TextCommand):
def run(self, edit,ver):
os.system("start /D D:\\project\\"+ver+" test.exe")
网友评论