我的sublime 3配置

安装主题:

使用的是cobalt2主题,下载地址为:https://github.com/wesbos/cobalt2,更多主题可参考此链接(http://www.itbulu.com/20-sublime-themes.html)。

下载主题后,点击 Preferences -> Browse Packages,将会打开 Packages 文件夹,把下载的主题解压在这个路径,并改名为 “Theme - Cobalt2”。

点击 Preferences -> Settings - User,将会打开 Preferences.sublime-settings 文件,在里面添加如下代码:

{
    "auto_find_in_selection": true,
    "color_scheme": "Packages/Theme - Cobalt2/cobalt2.tmTheme",
    "default_line_ending": "unix",
    "draw_minimap_border": true,
    "font_size": 17,
    "highlight_line": true,
    "ignored_packages":
    [
        "Vintage"
    ],
    "save_on_focus_lost": true,
    "show_encoding": true,
    "spell_check": false,
    "tab_size": 4,
    "theme": "Cobalt2.sublime-theme",
    "translate_tabs_to_spaces": true,
    "trim_automatic_white_space": true,
    "trim_trailing_white_space_on_save": true,
    "update_check": false,
    "word_wrap": false
}

保存并重启即可。

安装插件:

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

此后就可以按 Ctrl + Shift + P 组合键调出命令框,输入 install 再回车,分别输入要下载的插件AutoPep8、Pylinter、SublimeCodeIntel下载并安装。其中AutoPep8按PEP8风格自动排版Python代码;Pylinter可以对Python的语法以及规范化进行检查;SublimeCodeIntel是一款代码自动补全引擎。

随后利用pip install Pylint安装Pylint,并配置路径:打开 Preferences -> Package Settings -> Pylinter -> Settings - Default,配置如下:

{
    // When versbose is 'true', various messages will be written to the console.
    // values: true or false
    "verbose": true,
    // The full path to the Python executable you want to
    // run Pylint with or simply use 'python'.
    "python_bin": "python",
    // The following paths will be added Pylint's Python path
    "python_path": [
        "C:/Python27",
                   ],
    // Optionally set the working directory
    "working_dir": null,
    // Full path to the lint.py module in the pylint package
    "pylint_path": "C:/Python27/Lib/site-packages/pylint/lint.py",
    // Optional full path to a Pylint configuration file
    "pylint_rc": null,
    // Set to true to automtically run Pylint on save
    "run_on_save": true,
    // Set to true to use graphical error icons
    "use_icons": true,
    "disable_outline": false,
    // Status messages stay as long as cursor is on an error line
    "message_stay": false,
    // Ignore Pylint error types. Possible values:
    // "R" : Refactor for a "good practice" metric violation
    // "C" : Convention for coding standard violation
    // "W" : Warning for stylistic problems, or minor programming issues
    // "E" : Error for important programming issues (i.e. most probably bug)
    // "F" : Fatal for errors which prevented further processing
    "ignore": ["R", "C"],
    // a list of strings of individual errors to disable, ex: ["C0301"]
    "disable": [],
    "plugins": []
}

在里面改几个路径:python_path 的路径填上 python 的安装路径(即 python.exe 所在路径)、pylint_path 的路径填上Pylint的路径(比如我的是:“C:/Python27/Lib/site-packages/pylint/lint.py”)。另外,为了更好的看到错误信息,我将verbose以及use_icons都设置为true,同时为了减少没必要的警告和提示,可以选择设置ignore为[“R”, “C”]。

此时打开一个 .py 文件,按 Ctrl + B 执行即可。