You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS Code教程:如何让大括号、圆括号和方括号显示为粗体

问题:主题中括号类标点显示暗淡的优化需求

括号显示暗淡的编辑器截图

我喜爱当前的配色主题,但不满大括号、方括号和圆括号显示得暗淡模糊。

我已成功将大括号设置为粗体,配置代码如下:

"editor.tokenColorCustomizations":
{
    "textMateRules":
    [{
        "scope": ["punctuation"],
        "settings": {"fontStyle": "bold"}
    }]
},

该配置仅带来小幅改善,圆括号和方括号依旧非常暗淡。我尝试了其他设置,但未找到影响圆括号和方括号的对应配置项,恳请各位提供帮助。


解决方案

1. 定位括号的精准作用域

VS Code中不同类型的括号对应不同的TextMate作用域,你可以通过「开发者: 检查编辑器令牌和作用域」命令(快捷键Ctrl+Shift+P/Cmd+Shift+P调用),将光标放在目标括号上,查看它的具体作用域标签。

常见括号的标准作用域:

  • 大括号:punctuation.section.braces
  • 方括号:punctuation.section.brackets
  • 圆括号:punctuation.section.parentheses

2. 针对性配置示例

替换现有editor.tokenColorCustomizations配置,直接指定括号的作用域并设置高亮颜色和粗体:

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": [
                "punctuation.section.braces",
                "punctuation.section.brackets",
                "punctuation.section.parentheses"
            ],
            "settings": {
                "foreground": "#ffd700", // 替换为你想要的亮色,如金色、白色等
                "fontStyle": "bold"
            }
        }
    ]
}

3. 覆盖全类型括号的进阶配置

如果需要适配所有场景的括号(比如HTML标签括号、函数参数括号),可以扩大作用域匹配范围:

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": [
                "punctuation.section",
                "punctuation.definition.tag",
                "punctuation.definition.parameters"
            ],
            "settings": {
                "foreground": "#e6e6e6", // 浅灰色适配多数深色主题
                "fontStyle": "bold"
            }
        }
    ]
}

内容的提问来源于stack exchange,提问作者Adson Cicilioti

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 08:43:10