安装SublimeREPL后,每次在ST(Sublime Text)中打开Python命令窗口都需要点击Tools->SublimeREPL->Python->Python,比较麻烦。所以,需要为该命令设置快捷键,方法如下:
点击Preferences->Key Bindings 后在Default(Windows).sublime-keymap-User文件的最外层方括号中输入以下内容:
{ "keys": ["ctrl+alt+p"], "command": "run_existing_window_command", "args":
{
"id": "repl_python",
"file": "config/Python/Main.sublime-menu"
}
}
如果想为Tools->SublimeREPL->Python菜单下的其他命令指定快捷键,可以查阅config/Python/Default.sublime-commands
文件,找到菜单命令对应的id,用其替换上述内容中的id即可。Default.sublime-commands文件内容如下:
[
{
"caption": "SublimeREPL: Python",
"command": "run_existing_window_command", "args":
{
"id": "repl_python",
"file": "config/Python/Main.sublime-menu"
}
},
{
"caption": "SublimeREPL: Python - PDB current file",
"command": "run_existing_window_command", "args":
{
"id": "repl_python_pdb",
"file": "config/Python/Main.sublime-menu"
}
},
{
"caption": "SublimeREPL: Python - RUN current file",
"command": "run_existing_window_command", "args":
{
"id": "repl_python_run",
"file": "config/Python/Main.sublime-menu"
}
},
{
"command": "python_virtualenv_repl",
"caption": "SublimeREPL: Python - virtualenv"
},
{
"caption": "SublimeREPL: Python - IPython",
"command": "run_existing_window_command", "args":
{
"id": "repl_python_ipython",
"file": "config/Python/Main.sublime-menu"
}
}
]
注意:keys
的值大小写敏感。
保存后立即生效,以后按”ctrl+alt+p”就可以直接打开Python命令窗口了。
参考文献