1 .安装Package Control
从菜单 View - Show Console 或者 ctrl + ~ 快捷键,调出 console。将以下 Python 代码粘贴进去并 enter 执行,不出意外即完成安装。以下提供 ST3 和 ST2 的安装代码:
Sublime Text 3:
import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())
手动下载插件 https://packagecontrol.io/browse
2 .安装sideBarEnhancements侧边栏右键增效插件
安装过程如上,现在来说说怎么改变侧边栏大小,安装要调整侧栏等显示需要修改皮肤配置,安装 PackageResourceViewer 插件可以方便查找及修改,直接 Ctrl+Shift+P - Install Package 中查找安装不表。安装PackageResourceViewer,再Ctrl+Shift+P,查找 PackageResourceViewer: Open Resource
接下去根据你所用的主题皮肤走,
继续选择如下
修改侧栏字体:查找 sidebar_label 加上: “font.size”: 14,
修改侧栏树间距:查找 sidebar_tree修改: “row_padding”: [26, 10],“indent”: 20 等
修改标签栏:在主题配置文件(上述文件)中查找 tab_label ,修改 “font.size”,
(推荐安装主题Boxy theme,各种设置可以手动点击完成,安装方法同上述插件安装方式)
3.安装anaconda插件
按住"ctrl + shift + P",先输入install,然后直接输入anaconda,回车或者点击完成安装,安装Anaconda插件完成之后,会看到如下选项栏,说明Anaconda安装成功
选择Settings选项,搜索一下关键词,讲false改成true,Ctrl+S保存
{
"python_interpreter": "/usr/bin/python3",
"suppress_word_completions":true,
"suppress_explicit_completions":true,
"complete_parameters":false,
}
然后代码便可以自动提示了。
可以使用ctrl+alt+R
格式化代码(2019-4-21,如果发现不管用,可能与其他插件快捷键冲突,此时打开preference->anaconda->key binding修改成其他的就可以了)
{
"command": "anaconda_auto_format", "keys": ["ctrl+alt+q"], "context": [
{"key": "selector", "operator": "equal", "operand": "source.python"}
]},
此外,在Python代码中,右击某一个函数,选择anaconda–Goto Definition可以查看函数源码
4.新建编译环境
deepin Python2.x和Python3.x都存在,之前安装了Anaconda
(看另一篇http://blog.csdn.net/Co_zy/article/details/72422232),
首先将默认改为Anaconda的Python版本,编辑~/.bashrc
export PATH="/home/aaa/anaconda3/bin:$PATH"
source ~/.bashrc
之后点击Tools-Build System-New Build System
在新文件中输入如下,注意路径
(新建文件的存放位置/home/aaa/.config/sublime-text-3/Packages/User)
{
"cmd": ["/home/aaa/anaconda3/envs/my_python/bin/python", "-u" ,"$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
之后保存为python3.sublime-build。
别忘记下次Ctrl+B时先在Tools-Build System选择python3.
5.安装Python交互解释器
两种快捷键F1、F2
安装 SublimeREPL
Ctrl+shift+p 键入 install packages稍等片刻后 键入 SublimeREPL 安装即可通过选项Tools->SublimeREPL->Python就可以看到效果了.
键位绑定
当然每次通过Tools->SublimeREPL->Python这样的方式比较繁琐将这样的操作和一个按键如F1绑定后,就会方便很多啦e.g.打开Preferences->Key Bindings-User,复制下面代码:
{"keys":["f1"],
"caption": "SublimeREPL: Python",
"command": "run_existing_window_command", "args":
{"id": "repl_python",
"file": "config/Python/Main.sublime-menu"}}
可交互式
{"keys":["f2"],
"caption": "SublimeREPL: Python - RUN current file",
"command": "run_existing_window_command", "args":
{"id": "repl_python_run",
"file": "config/Python/Main.sublime-menu"}}
更改路径
编辑一下路径文件
/home/aaa/.config/sublime-text-3/Packages/SublimeREPL/config/Python/Main.sublime-menu
或者点击 Preference-Browse package
更改如下两处,下图为Python3的,如果想更改为Anaconda Python的,则更改为你新建的环境路径
/home/numb/anaconda3/envs/my_aaa/bin/python
6.安装的包迁移
参考
https://www.jianshu.com/p/9d8aa8b76a7f
把下图这两个文件夹的内容放到新Sublime text3的 Packages 和Installed Packages中。然后重启就可以。
C:\Users\aaa\AppData\Roaming\Sublime Text 3
7.用户设置
配置1
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.sublime-color-scheme",
"dpi_scale": 1.0,
"font_face": "YaHei Consolas Hybrid",
"font_options":
[
"gdi"
],
"font_size": 13,
"ignored_packages":
[
"Vintage"
],
"indent": 20,
"row_padding":
[
28,
10
],
"save_on_focus_lost": true,
"tab_size": 4,
"theme": "Adaptive.sublime-theme",
"theme_sidebar_close_always_visible": true,
"theme_sidebar_heading_bold": true,
"theme_sidebar_indent_xl": true,
"theme_statusbar_font_xl": true,
"theme_statusbar_label_bold": true,
"theme_statusbar_size_md": true,
"theme_statusbar_size_xl": true,
"translate_tabs_to_spaces": true,
"update_check": false
}
配置2 2019/11/28
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.sublime-color-scheme",
"dpi_scale": 1.0,
"font_face": "YaHei Consolas Hybrid",
"font_size": 13,
"ignored_packages":
[
"Vintage"
],
"tab_size": 4,
"theme": "Adaptive.sublime-theme",
"theme_font_options":
[
"gdi"
],
"update_check": false,
"word_wrap": "auto"
}
配置文件3(早期的了)
前段时间升级后,导致YaHei Consolas Hybrid
字体在英文空格下非常小,更换下面字体后,解决问题
{
"font_face": "WenQuanYi Micro Hei Mono",
//YaHei Consolas Hybrid
"font_size": 17,
"ignored_packages":
[
"Vintage"
],
"save_on_focus_lost": true
}
字体下载链接
https://sourceforge.net/projects/wqy/files/wqy-microhei/0.2.0-beta/wqy-microhei-0.2.0-beta.tar.gz/download