首页 > 代码库 > VS Code 配置 前端

VS Code 配置 前端

用户设置

打开 文件 > 首选项 > 用户设置(U),(忽略覆盖工作区提示)

{
   // 控制字体系列。
    "editor.fontFamily": "Consolas, ‘Courier New‘, monospace,‘宋体‘",
    // 以像素为单位控制字号。
    "editor.fontSize": 18,
    // 控制选取范围是否有圆角
    "editor.roundedSelection": false,
    // 建议小组件的字号
    "editor.suggestFontSize": 16,
    // 在“打开的编辑器”窗格中显示的编辑器数量。将其设置为 0 可隐藏窗格。
    "explorer.openEditors.visible": 0,
    // 是否已启用自动刷新
    "git.autorefresh": false,
    // 是否启用了自动提取。
    "git.autofetch": false,
    // 以像素为单位控制终端的字号,这是 editor.fontSize 的默认值。
    "terminal.integrated.fontSize": 14,
    // 控制终端游标是否闪烁。
    "terminal.integrated.cursorBlinking": true,
    // 一个制表符等于的空格数。该设置在 `editor.detectIndentation` 启用时根据文件内容进行重写。
    "editor.tabSize": 2,
    // Tab Size
    "beautify.tabSize": 2
}

用户代码片段

打开文件 > 首选项 > 用户代码片段 >(搜索代码语言)

HTML片段

{
    "ss": {
        "prefix": "ss",
        "body": [
            "<script src=http://www.mamicode.com/"$1\"></script>"
        ],
        "description": "<script src=http://www.mamicode.com/"...\"></script>"
    },
    "html5": {
        "prefix": "html5",
        "body": [
            "<!DOCTYPE html>",
            "<html lang=\"zh-CN\">",
            "",
            "<head>",
            "  <meta charset=\"UTF-8\">",
            "  <meta name=\"viewport\" content=\"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0\">",
            "  <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">",
            "  <title>${1:Document}</title>",
            "</head>",
            "",
            "<body>",
            "  $2",
            "</body>",
            "",
            "</html>"
        ],
        "description": "HTML5"
    }
}

JavaScript / JavaScript React

{
    "cl": {
        "prefix": "cl",
        "body": [
            "console.log($1)"
        ],
        "description": "console.log(‘‘)"
    },
    "dg": {
        "prefix": "dg",
        "body": [
            "document.getElementById($1)"
        ],
        "description": "document.getElementById(id)"
    },
    "jsdoc": {
        "prefix": "__",
        "body": [
            "/**",
            " * $1",
            " */"
        ],
        "description": "/** */"
    }
}

插件(主要开发React)

提示:VS Code自带有代码格式化功能,可以格式化HTML、CSS、JavaScript、JSON文件,格式JSX文件时需要设置缩进方式为空格·

Auto Close Tag (自动关闭HTML标签)
Auto Rename Tag (HTML标签自动改名)
Babel ES6/ES7 
Beautify css/sass/scss/less
Brackets Light (主题)
Complete JSDoc Tags (js文档注释提示)
Git History (查看git提交记录)
HTML CSS Support (HTML中提示可用的class)
npm Intellisense (提示可以require的模块名称)
One Dark Theme (主题)
Path Intellisense (路径补全)
Reactjs code snippets (reactjs代码提示)
Sass
SCSS IntelliSense
Sublime Babel
VSCode Great Icons (文件图标)
vscode-icons (文件图标)

主题、文件图标推荐

  • 主题我用的是:Brackets Light (个人喜欢亮色)
  • 文件图标我用的是:VSCode Great Icons 
 

VS Code 配置 前端