sublime text 3 環境設置


 1. 設置build system 環境

 tool -> build system -> new build system ,粘貼以下代碼並保存

{
"cmd":["python.exe", "-u", "$file"],
"path":"C:/Users/Sablier/AppData/Local/Programs/Python/Python37", 
// 注意:路徑根據自己的python安裝路徑而定 "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "selector": "source.python", "encoding": "cp936" ,
// 識別中文環境 }

 

//ctrl + B 執行程序
//ctrl + shift + c 終止程序
//ctrl + shift + P 加載控制台

 

 

2.為cancel build 建立快捷鍵

tool - > cancel build
可中止程序運行
快捷鍵中是ctrl+break
然而現在的大多數鍵盤已經不好按break鍵了,於是要修改鍵位
preferences - > key bindings
在左邊搜索cance_build,模仿左邊的語法在右邊加上自己的自定義

{ "keys": ["ctrl+shift+c"], "command": "cancel_build" },

  

 

3. 安裝sublime REPL 交互插件

1. Ctrl+shift+p,在彈出的對話框中輸入 packages control 安裝 packages control 環境, 並重啟sublime

2. Ctrl+shift+p,在彈出的對話框中輸入install packages 等待 packages control 初始化完成,鍵入sublime REPL 搜索並安裝。重啟sublime。

3. 配置 python3 運行環境(如果電腦上只有一個版本的python,則可以不用執行。如果同時有 python2 和 3 則需要配置單獨的 python3 啟動環境)

  Packages -> Browse Package 找到 SublimeREPL的文件夾 -> config (語言版本文件夾),新建 python3 文件夾;

  進入python3文件夾,新建 Default.sublime-commands 和 Menu.sublime-menu 兩個文件(模仿Python文件夾);

  在 Default.sublime-commands 中黏貼以下數據並保存:

// 我們Python3目前只需要能打開shell運行,和運行這個腳本,兩個功能,因此就只要包含Python3.5 和 Python3.5 – Run current file兩項就好了(本行不要復制)

[
{
"caption": "SublimeREPL: Python3",
"command": "run_existing_window_command", "args":
{
"id": "repl_python3",
"file": "config/Python3/Main.sublime-menu"
}
},

{
"caption": "SublimeREPL: Python3 - RUN current file",
"command": "run_existing_window_command", "args":
{
"id": "repl_python3_run",
"file": "config/Python3/Main.sublime-menu"
}
}
]

  在 Menu.sublime-menu 中粘貼以下數據並保存:

[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "R",
"id": "SublimeREPL",
"children":
[{
"caption": "Python3", "id": "Python3", "children":
[{
"command": "repl_open", "caption": "Python3", "id": "repl_python3", "mnemonic": "P", "args": { "type": "subprocess", "encoding": "utf8", "cmd": ["python3", "-i", "-u"], "cwd": "$file_path", "syntax": "Packages/Python/Python.tmLanguage", "external_id": "python3", "extend_env": {"PYTHONIOENCODING": "utf-8"} } }, {
"command": "repl_open", "caption": "Python3 - RUN current file", "id": "repl_python3_run", "mnemonic": "R", "args": { "type": "subprocess", "encoding": "utf8", "cmd": ["python3", "-u", "$file_basename"], "cwd": "$file_path", "syntax": "Packages/Python/Python.tmLanguage", "external_id": "python3", "extend_env": {"PYTHONIOENCODING": "utf-8"} } } ]} ] }] } ]

  

4. preferences - > key bindings 粘貼以下代碼,注意只能有一個[],設定F5為sublimeREPL -> python3 -> RUN current file 快捷鍵。

{
"keys":["f5"],
"caption": "SublimeREPL: Python3 - RUN current file",
"command": "run_existing_window_command",
"args":{
"id": "repl_python3_run",
"file": "config/Python3/Main.sublime-menu"
}
}    


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM