time-geekbang

13 | 优化你的编辑器设置

★为什么需要?

之前主要介绍了编辑器的功能,并且是尽量介绍编辑器默认推荐的设置。但在实际工作中,我们是需要根据自己的个人喜好以及项目的不同特性来对编辑器进行一定修改的。

话说,项目的不同特性指的是什么呢?——用不同语言写的项目吗?比如我用markdown写笔记等

★怎么引入这话题?

通过对比来引入,比如一个是默认编辑器设置的呈现,一个是优化过后的呈现……

★六个变化(决定了编辑器看起来怎么样)

修改7处设置,形成6个变化。

注意:这几个设置都是被大家频繁使用的,而且是用于个性化定制编辑器的设置

★其它设置(决定我们在编辑器里的书写体验)

★小Tip

评价一下以上的设置:

那么有哪些设置可让人惊喜和意外呢?

该设置解决的痛点:

当你按下 Cmd + N (Windows 上是 Ctrl + N)在编辑器里创建一个新文件的时候,这个新的文件会被识别为普通文本文件,你在里面书写内容时并没有合适的语法高亮和自动补全,所以你可能会经常看到有些用户,创建了新的空文件后,然后再去调整文件的语言类型

做法:

通过把 “files.defaultLanguage” 设置为你想要的语言,比如说,把它设置成 “markdown”,那么创建空文件的时候,VS Code 就会把它当作一个 Markdown 文件,然后你在里面能够得到 Markdown 的所有语言支持。

应用场景:

吕大佬说:

我在工作的时候,也会拿 VS Code 来写会议记录,当突然有了一个新的想法,我就会立刻创建新文件,无需任何改动,就能够书写各种 Markdown 的语法,并且得到正确的代码高亮。这就是我心目中的最佳编辑器设置。

总之,这个在做笔记的时候,比较方便吧!

让我惊喜和意味的还有「保存后就格式化」

★总结

1565240496910

★Q&A

①为CSS排序?

需要安装csscomb插件。

 "csscomb.preset": {
    "remove-empty-rulesets": true,
    "always-semicolon": true,
    "color-case": "lower",
    "block-indent": "  ",
    "color-shorthand": true,
    "element-case": "lower",
    "eof-newline": true,
    "leading-zero": false,
    "quotes": "double",
    "sort-order-fallback": "abc",
    "space-before-colon": "",
    "space-after-colon": " ",
    "space-before-combinator": " ",
    "space-after-combinator": " ",
    "space-between-declarations": "\n",
    "space-before-opening-brace": " ",
    "space-after-opening-brace": "\n",
    "space-after-selector-delimiter": "\n",
    "space-before-selector-delimiter": "",
    "space-before-closing-brace": "\n",
    "strip-spaces": true,
    "tab-size": true,
    "unitless-zero": true,
    "vendor-prefix-align": true,
    "sort-order": [
      "$variable",
      "$include",
      "$extend",
      "$import",
      "content",
      // 位置
      "position",
      "top",
      "right",
      "bottom",
      "left",
      "z-index",
      "float",
      "clear",
      "display",
      "flex-align",
      "flex-flow",
      "flex-direction",
      "flex-order",
      "flex-pack",
      "flex-wrap",
      "justify-content",
      "align-content",
      "align-items",
      "align-self",
      "order",
      "flex",
      "flex-basis",
      "flex-grow",
      "flex-shrink",
      // 大小
      "box-sizing",
      "overflow",
      "overflow-x",
      "overflow-y",
      "width",
      "min-width",
      "max-width",
      "height",
      "min-height",
      "max-height",
      "padding",
      "padding-top",
      "padding-right",
      "padding-bottom",
      "padding-left",
      "margin",
      "margin-top",
      "margin-right",
      "margin-bottom",
      "margin-left",
      "margin-collapse",
      "margin-top-collapse",
      "margin-right-collapse",
      "margin-bottom-collapse",
      "margin-left-collapse",
      "clip",
      "clip-path",
      "color",
      "counter-reset",
      "counter-increment",
      "direction",
      // 文字
      "font",
      "font-family",
      "font-feature-settings",
      "font-size",
      "font-kerning",
      "font-smoothing",
      "font-stretch",
      "font-style",
      "font-variant",
      "font-weight",
      "hanging-punctuation",
      "hyphens",
      "quotes",
      "line-height",
      "letter-spacing",
      "text-align",
      "text-decoration",
      "text-emphasis",
      "text-emphasis-color",
      "text-emphasis-position",
      "text-emphasis-style",
      "text-indent",
      "text-justify",
      "text-overflow",
      "text-overflow-ellipsis",
      "text-overflow-mode",
      "text-rendering",
      "text-size-adjust",
      "text-shadow",
      "text-transform",
      "word-break",
      "word-spacing",
      "word-wrap",
      "word-break",
      "tab-size",
      "vertical-align",
      "white-space",
      "list-style",
      "list-style-image",
      "list-style-position",
      "list-style-type",
      "appearance",
      // 背景
      "background",
      "background-color",
      "background-attachment",
      "background-clip",
      "background-image",
      "background-repeat",
      "background-repeat-x",
      "background-repeat-y",
      "background-position",
      "background-position-x",
      "background-position-y",
      "background-origin",
      "background-size",
      "box-decoration-break",
      "box-shadow",
      "border",
      "border-collapse",
      "border-top",
      "border-right",
      "border-bottom",
      "border-left",
      "border-color",
      "border-image",
      "border-top-color",
      "border-right-color",
      "border-bottom-color",
      "border-left-color",
      "border-spacing",
      "border-style",
      "border-top-style",
      "border-right-style",
      "border-bottom-style",
      "border-left-style",
      "border-width",
      "border-top-width",
      "border-right-width",
      "border-bottom-width",
      "border-left-width",
      "border-radius",
      "border-top-right-radius",
      "border-bottom-right-radius",
      "border-bottom-left-radius",
      "border-top-left-radius",
      "border-radius-topright",
      "border-radius-bottomright",
      "border-radius-bottomleft",
      "border-radius-topleft",
      "outline",
      "outline-width",
      "outline-style",
      "outline-color",
      "outline-offset",
      "perspective",
      "perspective-origin",
      "table-layout",
      // 其他
      "transform",
      "transform-origin",
      "transform-style",
      "animation",
      "animation-delay",
      "animation-duration",
      "animation-iteration-count",
      "animation-name",
      "animation-play-state",
      "animation-timing-function",
      "animation-fill-mode",
      "backface-visibility",
      "transition",
      "transition-delay",
      "transition-duration",
      "transition-property",
      "transition-timing-function",
      "will-change",
      "cursor",
      "opacity",
      "filter",
      "visibility",
      "zoom",
      "marks",
      "page-break",
      "page-break-before",
      "page-break-inside",
      "page-break-after",
      "pointer-events",
      "resize",
      "unicode-bidi",
      "user-select",
      "scrollbar",
      "widows"
    ]
  },

➹:CSS 属性排序千千万,我只爱那一种 · Issue #13 · wayou/wayou.github.io

➹:vscode 中使用 csscomb - xianshenglu - 博客园

②Vue编码风格?

  1. vue-style-beautify——可结合csscomb设置!

➹:在 vscode 中统一 vue 编码风格 - Web技术试炼地

③json文件注释折叠?

没有这个语法啊!

➹:Basic Editing in Visual Studio Code

"files.defaultLanguage": ""无效?

其实是有效的啊!

"files.defaultLanguage": "markdown"

是小写的m,而不是大写的M

➹:“files.defaultLanguage” does not work · Issue #40994 · microsoft/vscode

⑤换一款颜色主题?eva theme?

Bracket Pair Colorizer 设置:

"bracketPairColorizer.showHorizontalScopeLine": false,
"bracketPairColorizer.showVerticalScopeLine": false,
"bracketPairColorizer.consecutivePairColors": [
        "()",
        "[]",
        "{}",
        [
        "#838FA7",
        "#A78CFA",
        "#56B7C3",
        "#FF9070"
        ],
        "#e51400"
    ]
"bracketPairColorizer.showHorizontalScopeLine": false,
"bracketPairColorizer.showVerticalScopeLine": false,
"bracketPairColorizer.consecutivePairColors": [
        "()",
        "[]",
        "{}",
        [
        "#5D5D5FD8",
        "#7C4DFF",
        "#00BEC4",
        "#ff6500"
        ],
        "#e51400"
    ]

➹:Eva-Theme/README_CN.md at master · fisheva/Eva-Theme

⑥下载好看的字体?

➹:Montserrat Font Free by Julieta Ulanovsky » Font Squirrel

⑦保存后格式化,自动加分号和加双引号?

➹:Emmet - Vetur

➹:深入浅出eslint——关于我学习eslint的心得 - 掘金