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

use*_*188 3 comments visual-studio-code vscode-settings

我们可以在 VS Code中使除注释之外的所有文本都显示为粗体吗?
我试过使用,"editor.fontWeight": "bold"但这会使包括评论在内的所有内容都加粗。

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

编辑器截图

Lau*_*ost 7

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

但是,您可以将除注释之外的所有内容设为粗体

  • 打开settings.json Ctrl+Shift+P ?输入“打开设置(JSON)”?进入)
  • 粘贴下面的条目并保存以使所有文本加粗,注释除外

"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": ""
            }
        }]
    }
Run Code Online (Sandbox Code Playgroud)

如果您的 settings.json 不包含任何其他条目,只需将上述内容包装在{ }.
您可以在此处阅读有关在 VS Code 中自定义编辑器文本的更多信息。