无法使用sublimetext3中的热键运行py文件

问题描述 投票:1回答:1

我已将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"
    }
},

]

hot key configuration for my sublimeREPL

当我按F2或F1时,没有任何事情发生。

python-3.x sublimetext3 sublimerepl
1个回答
0
投票

似乎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键是一个带有commands和args的字典列表。我们将把它们复制到sublime-keymap文件中,并替换已经存在的commandargs。例如,打开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现在应该像过去一样工作。

© www.soinside.com 2019 - 2024. All rights reserved.