让你的VS Code性感起来,italic font

6,920 阅读1分钟

之前一直用WebStorm编写代码,最近转到VS Code后,对WebStorm的斜体字样式念念不忘,由于本人是个颜值控,比较喜欢好看的字体,骚气的代码配色,所以想办法让VS Code也支持斜体字和连字符特性等,

连字符特性很好解决,只需一行设置即可:

  "editor.fontLigatures": true

前提是你设置的编辑器当前字体要支持Font Ligatures特性,比如经典的Fira Code字体,以前非常迷这款字体,但是你们懂的,任何好看的东西,久了都会没新鲜感...

后来喜欢上了Operator Mono, 非常漂亮的字体, 本文图示所用字体采用的就是这款:

Alt text

这个斜体配置,需要在自定义设置中添加如下配置项:

"editor.tokenColorCustomizations": {
    "textMateRules": [
      {
        "name": "italic font",
        "scope": [
          "comment",
          "keyword",
          "storage",
          "keyword.control",
          "keyword.control.from",
          "keyword.control.flow",
          "keyword.operator.new",
          "keyword.control.import",
          "keyword.control.export",
          "keyword.control.default",
          "keyword.control.trycatch",
          "keyword.control.conditional",
          "storage.type",
          "storage.type.class",
          "storage.modifier.tsx",
          "storage.type.function",
          "storage.modifier.async",
          "variable.language",
          "variable.language.this",
          "variable.language.super",
          "meta.class",
          "meta.var.expr",
          "constant.language.null",
          "support.type.primitive",
          "entity.name.method.js",
          "entity.other.attribute-name",
          "punctuation.definition.comment",
          "text.html.basic entity.other.attribute-name",
          "tag.decorator.js entity.name.tag.js",
          "tag.decorator.js punctuation.definition.tag.js",
          "source.js constant.other.object.key.js string.unquoted.label.js",
        ],
        "settings": {
          "fontStyle": "italic",
        }
      },
    ]
  },

以上配置,对js中的一些关键字可以完美支持italic字体,如果不满足你的要求,可以尝试自己添加配置,配置名称的查找可以通过:⇧⌘P -> inspect the scopes 来实现,具体参考VS Code官方文档

所谓萝卜白菜各有所爱,不喜勿喷,同时欢迎大家留言交流。