我已将sublime3更新到最新版本,然后我无法使用热键来运行我的py文件。这是我的热键配置:
[
{
"caption": "Tmpl: Create python",
"command": "sublime_tmpl",
"keys": ["ctrl+alt+p"], "args": {"type": "python"}
},
{
"keys":["f1"],
"caption": "SublimeREPL: Python",
"command": "run_existing_window_command", "args":
{
"id": "repl_python",
"file": "config/Python/Main.sublime-menu"
}
},
{
"keys":["f2"],
"caption": "SublimeREPL: Python - RUN current file",
"command": "run_existing_window_command", "args":
{
"id": "repl_python_run",
"file": "config/Python/Main.sublime-menu"
}
},
]
当我按F2或F1时,没有任何事情发生。
似乎Sublime Text 3 build 3200打破了run_existing_window_command
命令。正如在this answer中提到的,解决方案是调用SublimeREPL菜单项正在使用的命令。
如果导航到Sublime Text 3软件包目录(Windows上默认为AppData/Roaming/Sublime Text 3/
),则可以看到已安装的软件包。从这个目录,如果你打开SublimeREPL/config/Python/Main.sublime-menu
,你会看到一个大的ole json文件,看起来像这样:
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "R",
"id": "SublimeREPL",
"children":
[
{"caption": "Python",
"id": "Python",
"children":[
{"command": "repl_open",
"caption": "Python",
"id": "repl_python",
"mnemonic": "P",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["python", "-i", "-u"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
}
<---snip--->
]}
]
}]
}
]
请注意,最里面的children
键是一个带有command
s和args
的字典列表。我们将把它们复制到sublime-keymap
文件中,并替换已经存在的command
和args
。例如,打开python REPL的快捷方式现在看起来像:
"keys": ["f1"],
"command": "repl_open",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["python", "-u", "$file_basename"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
击中F1
现在应该像过去一样工作。