您的位置:首页 > 编程语言 > Python开发

sublime3配置python环境最佳实践

2017-10-21 10:55 525 查看

1.官网下载安装sublime

—– BEGIN LICENSE —–
TwitterInc
200 User License
EA7E-890007
1D77F72E 390CDD93 4DCBA022 FAF60790
61AA12C0 A37081C5 D0316412 4584D136
94D7F7D4 95BC8C1C 527DA828 560BB037
D1EDDD8C AE7B379F 50C9D69D B35179EF
2FE898C4 8E4277A8 555CE714 E1FB0E43
D5D52613 C3D12E98 BC49967F 7652EED2
9D2D2E61 67610860 6D338B72 5CF95C69
E36B85CC 84991F19 7575D828 470A92AB
—— END LICENSE ——


2.安装package control

按ctrl+`,然后输入 安装pc

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())


另一种方法: 点击菜单直接安装pc

ctrl+p 输入ip,安装插件

3.换主题,换肤

下载安装:

- predawn

- material theme

- sidebarenhance

替换设置-user

{
"theme": "Material-Theme-Darker.sublime-theme",
"color_scheme": "Packages/Predawn/predawn.tmTheme",

"material_theme_accent_graphite": true ,
"material_theme_compact_sidebar": true,

"file_exclude_patterns": ["*.pyc", "*.pyo", "*.exe", "*.dll", "*.obj","*.o", "*.a", "*.lib", "*.so", "*.dylib", "*.ncb", "*.sdf", "*.suo", "*.pdb", "*.idb", ".DS_Store", "*.class", "*.psd", "*.sublime-workspace"],

"font_face": "Source Code Pro",
"font_options":
[
"no_round"
],
"font_size": 20,
"bold_folder_labels": true,
"caret_extra_width": 1,
"caret_style": "phase",
"close_windows_when_empty": false,
"copy_with_empty_selection": false,
"drag_text": false,
"draw_minimap_border": true,
"enable_tab_scrolling": false,
"highlight_line": true,
"ignored_packages":
[
"Vintage"
],
"line_padding_bottom": 1,
"line_padding_top": 1,
"match_brackets_content": false,
"match_selection": false,
"match_tags": false,
"open_files_in_new_window": false,
"overlay_scroll_bars": "enabled",
"preview_on_click": false,
"scroll_past_end": true,
"scroll_speed": 5.0,
"show_full_path": false,
"sidebar_default": true,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"word_wrap": true,

"show_definitions": false,
"show_encoding": true,
"show_errors_inline": false,

"ensure_newline_at_eof_on_save": true,
"highlight_modified_tabs": true,
"use_simple_full_screen": true
}


配置python2 python3环境

工具–编译系统–添加

python27.sublime-build

{
"cmd": ["C:\\Users\\Administrator\\Envs\\py27env\\Scripts\\python.exe", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"quiet": true
}


python36.sublime-build

{
"cmd": ["C:\\Users\\Administrator\\Envs\\py36env\\Scripts\\python.exe", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"quiet": true
}


执行时候: 工具-编译系统-选择自己关联的python虚拟环境

安装anacoda

实现自动补全

实现自动格式化代码

{
"auto_formatting": true,
"autoformat_ignore":
[
"E309",
"E501"
],
"pep8_ignore":
[
"E309",
"E501"
],
"python_interpreter": "C:/Users/Administrator/Envs/py27env/Scripts/python.exe",
"suppress_word_completions": true,
"suppress_explicit_completions": true,
"complete_parameters": true,
"complete_all_parameters": false,
"anaconda_linter_underlines": true,
"anaconda_linter_mark_style": "none",
"display_signatures": false,
"disable_anaconda_completion": false
}


至此可以写py,ctrl+b,run起来

参考: https://github.com/CoreyMSchafer/dotfiles/tree/master/init

SublimeTmpl插件

实现ctrl+alt+p新建py文件,并添加 #!/…

SublimeTmpl:新建文件模板插件,可以支持多种语言例如Python、PHP等,下面的代码是我在配置文件中的配置信息

在settings - user中设置上自己的信息

{
"disable_keymap_actions": false, // "all"; "html,css"
"date_format": "%Y-%m-%d %H:%M:%S",
"attr": {
"author": "xl",
"email": "xx@xx.com.cn",
"link": "http://www.xx.com.cn/"
}
}


我将Python的创建模板命令也做了修改,在key bindings - user中添加了以下信息,意思是ctrl + alt + p就可以创建一个新的Python模板

[
{
"caption": "Tmpl: Create python", "command": "sublime_tmpl",
"keys": ["ctrl+alt+p"], "args": {"type": "python"}
},
]


插件列表



可能还有别的好用的插件,抽时间陆陆续续完善吧
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: