Sublime Text 3 python 配置及插件配置

Package Control 安装方法

1.通过快捷键 ctrl+` 或者 View > Show Console 打开控制台,然后粘贴相应的 Python 安装代码;

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

3.重启Sublime Text 3;

4.如果在Perferences->package settings中看到package control这一项,则安装成功。

用Package Control安装插件的方法:
  1. 按下Ctrl+Shift+P调出命令面板
  2. 输入install 调出 Install Package 选项并回车,然后在列表中选中要安装的插件。如图:img

Pylinter.sublime-settings 配置了pylinter 插件。我使用下面的配置让 Pyhton 在保存时自动规范,并对违反规范显示图标。

 1 {
 2     // Configure pylint's behavior
 3     "pylint_rc": "/Users/daniel/dev/pylintrc",
 4  
 5     // Show different icons for errors, warnings, etc.
 6     "use_icons": true,
 7  
 8     // Automatically run Pylinter when saving a Python document
 9     "run_on_save": true,
10  
11     // Don't hide pylint messages when moving the cursor
12     "message_stay": true
13 }

SublimeCodeIntel 插件

智能提示插件,这个插件的智能提示功能非常强大,可以自定义提示的内容库,我的Python智能提示设置

    {
	"Python": {
         "python":"D:/Python36/python.exe",
         "pythonExtraPaths":
             [
                 "D:/Python36",
                  "D:/Python36/DLLs",
                  "D:/Python36/Lib",
                  "D:/Python36/Lib/lib-tk",
                  "D:/Python36/Lib/site-packages"
             ]
         }
	} 

Python PEP8 Autoformat 插件

这是用来按PEP8自动格式化代码的。可以在包管理器中安装。快捷键 CTRL+SHIFT+R 自动格式化python代码

常用配置

 1 {
 2     "auto_complete": false,
 3     "caret_style": "solid",
 4     "ensure_newline_at_eof_on_save": true,
 5     "find_selected_text": true,
 6     "font_size": 11.0,
 7     "highlight_modified_tabs": true,
 8     "line_padding_bottom": 0,
 9     "line_padding_top": 0,
10     "scroll_past_end": false,
11     "show_minimap": false,
12     "tab_size": 4,
13     "translate_tabs_to_spaces": true,
14     "trim_trailing_white_space_on_save": true,
15     "wide_caret": true,
16     "word_wrap": true,
17 }

F12 或 CTRL+B 运行 py文件

如果是F12最好在py文件后加raw_input()否则CMD会一闪而过;

sublime text 3 Python代码补全

具体方法
点击Ctrl+Shift+P弹出
这里写图片描述
选择Install Package等待一会儿弹出下图小框,输入SublimeCodeintal点击安装即可,我这个是已经安装过,所以不会提示。
这里写图片描述
等待安装完成后,选择 Perference-Package Settings-SublimeCodeIntel-Settings-User,复制以下配置:

{ 
“codeintel_language_settings”: { 
	“Python3”: { 
	“python3”: “C:\Users\xmm\AppData\Local\Programs\Python\Python36\python.exe”, 
	“codeintel_scan_extra_dir”: [ 
	“C:\Users\xmm\AppData\Local\Programs\Python\Python36\DLLs”, 
	“C:\Users\xmm\AppData\Local\Programs\Python\Python36\Lib”, 
	“C:\Users\xmm\AppData\Local\Programs\Python\Python36\Lib\site-packages”, 
	“C:\Users\xmm\AppData\Local\Programs\Python\Python36\Lib\idlelib”, 
	“C:\Users\xmm\AppData\Local\Programs\Python\Python36\python36.zip”, 
	“C:\Users\xmm\AppData\Local\Programs\Python\Python36”, 
	“C:\Users\xmm\AppData\Local\Programs\Python\Python36\Lib\*”, 
		], 
“codeintel_scan_files_in_project”: true, 
“codeintel_selected_catalogs”: [] 
			}, 
	} 
} 

保存退出即可。

Emmet

编写前端代码必备,能实现快速编写html/css。

SublimeLinter

高亮提示代码错误

Alignment

对齐代码,让代码更美观(Ctrl+alt+a)

SublimeREPL

实现交互式编程(输入输出),使用方法详见接下来的python安装。

在sublime text 3中配置python编译环境

在sublime text 3的菜单栏中找到tools,选择bulid system–>new build system,将内容修改为如下:

{  "cmd": ["c:/Python36/python.exe", "-u", "$file"],                                                                       
 "file_regex": "^[ ]*File \"(...*?)\", line ([0-9])*",                                                                           
  "selector": "source.python"  }  

其中c:/Python36/python.exe改为在你电脑中python.exe的位置,这样通过ctrl+b就可以直接运行出结果。

img

4. sublimeREPL插件使用

sublimeREPL的主要是用于程序的交互,即可以实现数据的输入,详情如下:在菜单栏中找到tools–>sublimeREPL–>python–>python run current file点击即可运行程序

img

python" } ```

其中c:/Python36/python.exe改为在你电脑中python.exe的位置,这样通过ctrl+b就可以直接运行出结果。

sublimeREPL插件使用
sublimeREPL的主要是用于程序的交互,即可以实现数据的输入,详情如下:在菜单栏中找到tools–>sublimeREPL–>python–>python run current file点击即可运行程序

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值