在win10系统环境下,安装配置sublime 3,构建python和vue.js开发环境(插件)
阅读原文时间:2023年07月08日阅读:5

原文转载自「刘悦的技术博客」https://v3u.cn/a_id_131

疫情当下,最近一直在用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}

另外由于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"],
        }
    }
}

使用sublime3开发python和vue感觉相对硬核,但是和那些用vim的大神还是没法比,和vscode的区别就是系统占用确实少了很多,见下图:

原文转载自「刘悦的技术博客」 https://v3u.cn/a_id_131