SublimeText配置Python开发环境(交互、快捷打开REPL、⾃动补全,侧边栏
等)
SublimeText配置Python开发环境(交互、快捷打开 REPL、⾃动补全等)
0.效果图:
主题是:默认的
1. 基础配置、包安装等基础操作参考:
(主要是把包管理器(Package Control)安装好,⽅法见链接,命令⾏安装版本2和3命令有区别见)
把以下包装好:
SublimeREPL(命令⾏插件)
Jedi - Python autocompletion (⾃动补全)
sublimetmpl (快捷新建⽂件模板)
diffy (对⽐代码异同)
theme-Afterglow (侧边栏样式),setting ⾥设置 theme参数
2. ⾃动补全:jedi,装上就好了
3. 侧边栏的⽂件夹模式:
(1)project -> add folders to project 打开⼀个⽂件夹
(2)view -> Slide Bar -> Show Slide Bar
4. 侧边栏样式:
可参考
//修改settings
{
"color_inactive_tabs": true,
"color_scheme": "Packages/Color Scheme - Theme",
"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 键位绑定
以下可以参考简化版本:
(1)交互命令、命令id修改
可直接下载⽂件进⾏替换:
#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> 黏贴到以上代码段后,⽤逗号后分隔
<3>修改"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/Language",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
},
#此处为复制上⾯的,然后修改cmd 和 id
{"command": "repl_open",
"caption": "Python",
"id": "repl_python_new",
"mnemonic": "P",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cwd": "$file_path",
"syntax": "Packages/Language",
"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"
}
}
]

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。