VS Code:如何使所有文本加粗,评论除外?

VS Code: How to make all text bold, except the comments?

我们能否使除评论之外的所有文本在 VS Code 中显示为 粗体
我试过使用 "editor.fontWeight": "bold" 但这会使所有内容(包括评论)都变成粗体。

示例:在下面的屏幕截图中,除了评论(灰色)之外的所有文本都是粗体。

为评论设置不同的字体或字体大小目前不是 VS Code 中的标准功能。

但是你可以做除了注释之外的所有内容 粗体:

  • 打开 settings.json Ctrl+Shift+P → 输入 'Open Settings (JSON)' → Enter)
  • 粘贴下面的条目并保存以使所有文本变为粗体,评论除外:

"editor.tokenColorCustomizations": {
        "textMateRules": [{
            "scope": [
                "constant",
                "constant.character",
                "constant.character.escape",
                "constant.numeric",
                "constant.numeric.integer",
                "constant.numeric.float",
                "constant.numeric.hex",
                "constant.numeric.octal",
                "constant.other",
                "constant.regexp",
                "constant.rgb-value",
                "emphasis",
                "entity",
                "entity.name",
                "entity.name.class",
                "entity.name.function",
                "entity.name.method",
                "entity.name.section",
                "entity.name.selector",
                "entity.name.tag",
                "entity.name.type",
                "entity.other",
                "entity.other.attribute-name",
                "entity.other.inherited-class",
                "invalid",
                "invalid.deprecated",
                "invalid.illegal",
                "keyword",
                "keyword.control",
                "keyword.operator",
                "keyword.operator.new",
                "keyword.operator.assignment",
                "keyword.operator.arithmetic",
                "keyword.operator.logical",
                "keyword.other",
                "markup",
                "markup.bold",
                "markup.changed",
                "markup.deleted",
                "markup.heading",
                "markup.inline.raw",
                "markup.inserted",
                "markup.italic",
                "markup.list",
                "markup.list.numbered",
                "markup.list.unnumbered",
                "markup.other",
                "markup.quote",
                "markup.raw",
                "markup.underline",
                "markup.underline.link",
                "meta",
                "meta.block",
                "meta.cast",
                "meta.class",
                "meta.function",
                "meta.function-call",
                "meta.preprocessor",
                "meta.return-type",
                "meta.selector",
                "meta.tag",
                "meta.type.annotation",
                "meta.type",
                "punctuation.definition.string.begin",
                "punctuation.definition.string.end",
                "punctuation.separator",
                "punctuation.separator.continuation",
                "punctuation.terminator",
                "storage",
                "storage.modifier",
                "storage.type",
                "string",
                "string.interpolated",
                "string.other",
                "string.quoted",
                "string.quoted.double",
                "string.quoted.other",
                "string.quoted.single",
                "string.quoted.triple",
                "string.regexp",
                "string.unquoted",
                "strong",
                "support",
                "support.class",
                "support.constant",
                "support.function",
                "support.other",
                "support.type",
                "support.type.property-name",
                "support.variable",
                "variable",
                "variable.language",
                "variable.name",
                "variable.other",
                "variable.other.readwrite",
                "variable.parameter"
            ],
            "settings": {
                "fontStyle": "bold"
            }
          },{
            "scope": [
                "comment",
                "punctuation.definition.comment"
            ],
            "settings": {
                "fontStyle": ""
            }
        }]
    }

如果您的 settings.json 不包含任何其他条目,只需将上面的内容包装在 { } 中即可。
您可以在 VS Code here.

中阅读有关自定义编辑器文本的更多信息