最近一直在用mac下的虚拟机运行win10系统,由于在线人数过多,直播授课的时候使用vscode的时候内存暴涨,于是考虑切换回sublime3,毕竟编辑器要比ide要轻量的多,在此记录一下整个流程。
首先下载,sublime3软件安装包:https://www.sublimetext.com/
安装好后,安装python3.7,下载地址:https://www.python.org/,由于我之前已经安装过所以不赘述了,没有安装过的同学别忘了安装好以后在win10下要配置环境变量
编辑器和Python全都安装完成后,就是在sublime内配置python的开发环境
1:配置编译环境
打开sublime,依次点击菜单Tools-->Build System-->New Build System
将下面的代码贴到配置文件中去:
{
"cmd": ["c:/python37/python.exe","-u","$file"],
"file_regex":"^[ ]*File "(...*?)", line ([0-9]*)",
"selector":"source.python",
}
完成后点击左上角 file -- save 保存,命名为python3,使用默认路径直接保存
保存好之后,重启编辑器,然后新建一个test.py,输入代码,运行(ctrl+b)测试程序是否成功,记得保存文件后测试
还没完,sublime安装package control来管理和安装插件
使用Ctrl+\`快捷键或者通过View->Show Console菜单打开命令行,粘贴如下代码
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())
安装成功后:在Perferences->中看到package setting 和 package control 则表示安装成功
此时按下Ctrl+Shift+P调出插件命令面板,输入install后选择install package回车
这里推荐安装以下插件,可以让开发效率事半功倍
Anaconda
JavaScript Completions
SublimeLinter
SublimeLinter-pylint
AutoFileName
Python 3
SideBarEnhancements
Vue Syntax Highlight
Vuejs Complete Package
Vuejs Snippets
装完这些插件,再修改settings配置文件配置一下
{
"font_size": 10,
"index_files":false,
"ignored_packages":
[
"Vintage"
],
"save_on_focus_lost": true,
"theme": "Adaptive.sublime-theme",
"update_check": false,
"word_wrap": true
}
另外别忘了在设置中将anaconda的代码检查设置关闭:
Sublime > Preferences > Package Settings > Anaconda > Settings User 中设置关闭:
{“anaconda\_linting”: false}
除此以外,如果需要pylint帮你检查python语法的话,还需要单独安装以下
pip install pylint
另外由于python的语法检查工具pylint过于敏感,所以还需设置一下SublimeLinter的配置文件:
// SublimeLinter Settings - User
{
"linters": {
"pylint": {
// C0111 Missing docstring
// I0011 Warning locally suppressed using disable-msg
// I0012 Warning locally suppressed using disable-msg
// W0704 Except doesn't do anything Used when an except clause does nothing but "pass" and there is no "else" clause
// W0142 Used * or * magic* Used when a function or method is called using *args or **kwargs to dispatch arguments.
// W0212 Access to a protected member %s of a client class
// W0232 Class has no __init__ method Used when a class has no __init__ method, neither its parent classes.
// W0613 Unused argument %r Used when a function or method argument is not used.
// W0702 No exception's type specified Used when an except clause doesn't specify exceptions type to catch.
// R0201 Method could be a function
// W0614 Unused import XYZ from wildcard import
// R0914 Too many local variables
// R0912 Too many branches
// R0915 Too many statements
// R0913 Too many arguments
// R0904 Too many public methods
"args": ["--disable=C0111,I0011,I0012,W0704,W0142,W0212,W0232,W0613,W0702,R0201,W0614,R0914,R0912,R0915,R0913,R0904,R0801,C0411,W0611,C0412,C0326,C0103,R1705,C0305,C0413,C0301,C0330,W0123,E1101,R0903,C0304,C0303,W0622,C0121,,W0703,W0107,W0312"],
}
}
}
最后关于Sublime Text 3 最新注册码的问题
首先找到host文件,win10在:C:/Windows/System32/drivers/etc路径下面,修改之前别忘了设置一下文件权限,否则保存不了
将下面的代码加到最后:
0.0.0.0 license.sublimehq.com
0.0.0.0 45.55.255.55
0.0.0.0 45.55.41.223
127.0.0.1 www.sublimetext.com
127.0.0.1 sublimetext.com
127.0.0.1 sublimehq.com
127.0.0.1 telemetry.sublimehq.com
随后打开sublime text ,选择help-->enter license,将下面的代码内容复制到输入框中
— BEGIN LICENSE —–
ZYNGA INC.
50 User License
EA7E-811825
927BA117 84C9300F 4A0CCBC4 34A56B44
985E4562 59F2B63B CCCFF92F 0E646B83
0FD6487D 1507AE29 9CC4F9F5 0A6F32E3
0343D868 C18E2CD5 27641A71 25475648
309705B3 E468DDC4 1B766A18 7952D28C
E627DDBA 960A2153 69A2D98A C87C0607
45DC6049 8C04EC29 D18DFA40 442C680B
1342224D 44D90641 33A3B9F2 46AADB8F
—— END LICENSE ——
这样就可以永久破解了,使用sublime3开发python和vue感觉相对硬核,但是和那些用vim的大神还是没法比,和vscode的区别就是系统占用确实少了很多,见下图: