原来这很简单。我刚刚将以下内容添加到Packages/User/SublimeREPL/config/Python/Main.sublime-menu。选择此添加定义的菜单选项将执行 util_func.py 并放入 REPL。
[
{
"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", "PATH TO utility_func.py"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
}
]}
]
}]
}
]
记得把上面的PATH TO utility_func.py替换成正确的路径。