4

安装Package Control

  Sublime安装插件有两种方式,一种是直接下载安装包解压缩到Packages目录,另一种是通过Package Control组件来安装组件,后者更加的方便。

打开Sublime,按control + ` 打开控制台,粘贴如下代码到命令行并回车;

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

重启Sublime,在Perferences->Package Settings 中看到 Package Control,则表示安装成功。

安装SublimeLinter

  SublimeLinter是Sublime的一个代码检测工具插件。
安装SublimeLinter前必须安装node.js

  • 打开Sublime,按下 Ctrl+Shift+p 进入 Command Palette;

  • 输入install进入 Package Control: Install Package;

  • 输入SublimeLinter,选择SublimeLinter进行安装。


安装sublimeLinter-contrib-htmlhint

  可以把sublimeLinter-contrib-htmlhint看成是SublimeLinter的一个插件,sublimeLinter-contrib-htmlhint调用xg-htmlhint来进行语法检查。sublimeLinter-contrib-htmlhint 1.0.1版本有问题,所以我们使用1.0.0版本。

  • 前往Releases下载1.0.0的压缩包,解压并重命名为“SublimeLinter-contrib-htmlhint”,并放入Sublime的Package目录(菜单->Preferences->Browse
    Packages)

安装xg-htmlhint

图片描述

找到node.js的CMD窗口,输入以下命令;等待出现一堆数字版本号即为成功安装。

npm install -g xg-htmlhint

  此时打开Sublime Text3,xg-htmlhint就可以检测代码了,保存(cmd + S)的时候如果有错误会有错误提示。


安装jshint和csslint

打开Sublime_Txt3,按住Ctrl+Shift+P安装

Sublime​Linter-csslint   
Sublime​Linter-jshint

打开nodejs的CDM窗口,输入命令安装

npm install jshint
npm install csslint

SublimeLinter个性化配置

{
    "user": {
        "csslint_options": {
            "adjoining-classes": false,
            "box-model": false,
            "box-sizing": false,
            "compatible-vendor-prefixes": false,
            "floats": false,
            "font-sizes": false,
            "gradients": false,
            "important": false,
            "known-properties": false,
            "outline-none": false,
            "qualified-headings": false,
            "regex-selectors": false,
            "shorthand": false,
            "text-indent": false,
            "unique-headings": false,
            "universal-selector": false,
            "unqualified-attributes": false
        },
        "debug": false,
        "delay": 0.25,
        "error_color": "D02000",
        "gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
        "gutter_theme_excludes": [],
        "jshint_options": {
            "browser": true,
            "curly": true,
            "devel": true,
            "eqeqeq": true,
            "evil": true,
            "forin": true,
            "globals": {
                "$": true,
                "console": true,
                "document": true,
                "global": true,
                "grunt": true,
                "jQuery": true,
                "module": true,
                "setInterval": true,
                "setTimeout": true,
                "window": true
            },
            "jquery": true,
            "latedef": true,
            "noarg": true,
            "noempty": true,
            "quotmark": "single",
            "strict": false,
            "undef": true,
            "unused": "vars",
            "wsh": true
        },
        "lint_mode": "background",
        "linters": {
            "csslint": {
                "@disable": false,
                "args": [],
                "errors": "",
                "excludes": [],
                "ignore": "",
                "warnings": ""
            },
            "htmlhint": {
                "@disable": false,
                "args": [],
                "excludes": []
            },
            "jshint": {
                "@disable": false,
                "args": [],
                "excludes": []
            }
        },
        "mark_style": "outline",
        "no_column_highlights_line": false,
        "passive_warnings": false,
        "paths": {
            "linux": [],
            "osx": [],
            "windows": []
        },
        "python_paths": {
            "linux": [],
            "osx": [],
            "windows": []
        },
        "rc_search_limit": 3,
        "shell_timeout": 10,
        "show_errors_on_save": false,
        "show_marks_in_minimap": true,
        "sublimelinter": "save-only",
        "sublimelinter_executable_map": {
            "css": "C:/Program Files/nodejs/node.exe",
            "javascript": "C:/Program Files/nodejs/node.exe"
        },
        "sublimelinter_gutter_marks": true,
        "sublimelinter_popup_errors_on_save": true,
        "syntax_map": {
            "html (django)": "html",
            "html (rails)": "html",
            "html 5": "html",
            "javascript (babel)": "javascript",
            "magicpython": "python",
            "php": "html",
            "python django": "python"
        },
        "warning_color": "DDB700",
        "wrap_find": true
    }
}

凌l辰
170 声望7 粉丝

引用和评论

0 条评论