SublimeText配置Python開發環境(互動、快捷開啟 REPL、自動補全,側邊欄等)
阿新 • • 發佈:2019-01-06
SublimeText配置Python開發環境(互動、快捷開啟 REPL、自動補全等)
0.效果圖:
主題是:Blackboard
1. 基礎配置、包安裝等基礎操作參考:sublime text 3 + python配置,完整搭建及常用外掛安裝
(主要是把包管理器(Package Control)安裝好,方法見連結,命令列安裝版本2和3命令有區別見Package Control 的安裝)
把以下包裝好:
- SublimeREPL(命令列外掛)
- Jedi - Python autocompletion (自動補全)
sublimetmpl (快捷新建檔案模板)
2. 自動補全
3. 側邊欄的資料夾模式:
(1)project -> add folders to project 開啟一個資料夾
(2)view -> Slide Bar -> Show Slide Bar
4. 側邊欄樣式:
可參考知乎:sublime text3 可以手動修改側邊欄樣式麼?
//修改settings
{
"color_inactive_tabs": true,
"color_scheme": "Packages/Color Scheme - Default/Blackboard.tmTheme",
"enable_mathjax" : true,
"expand_tabs_on_save": true,
"font_size": 11,
"ignored_packages":
[
"Vintage"
],
"tabs": 4, // tab鍵佔4個空格位
"translate_tabs_to_spaces": true, //tab鍵自動轉化為空格
"update_check": false,
"tabs_small": true,
//這個樣式主題和上面的color_scheme不衝突(現在用最新版本的軟體,會有BUG可以考慮換個主題)
//"theme": "Afterglow.sublime-theme"
}
5. 互動和快捷鍵開啟REPL程式碼如下
在安裝了外掛SublimeREPL之後:
主要分為兩部分:
(1)config/Python/Main.sublime-menu 相應命令修改
(2)preference → key—binding 鍵位繫結
#config/Python/Main.sublime-menu
#具體位置在C:\Users\xxx(your name)\AppData\Roaming\Sublime Text 3\Packages\SublimeREPL\config\Python
(具體位置可能有出入在C盤直接搜“SublimeREPL”可以快速定位)
SublimeText 3176
此處主要有二點:
<1>複製多一份"command": "repl_open"對應的程式碼段
<2>修改"command": "repl_open"對應程式碼的id和cmd
{"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"}
}
},
#此處為複製上面的,然後修改cmd
{"command": "repl_open",
"caption": "Python",
"id": "repl_python_new",
"mnemonic": "P",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
}
2.鍵位配置程式碼如下:
key—binding
[
{
"caption": "Tmpl: Create python", "command": "sublime_tmpl",
"keys": ["alt+q"], "args": {"type": "python"}
},//以上快捷鍵,需要安裝外掛sublimetmpl
{"keys":["f5"],
"caption": "SublimeREPL: Python",
"command": "run_existing_window_command",
"args":{
"id": "repl_python_new",
"file": "config/Python/Main.sublime-menu"}
},
{ "keys": ["f4"],
"caption": "SublimeREPL:Python",
"command": "run_existing_window_command",
"args":
{
"id": "repl_python",
"file": "config/Python/Main.sublime-menu"
}
}
]