visual-studio-code - 在 VSCode 中自定义“反引号”内的文本颜色
问题描述
我能找到的在 Visual Studio Code 中处理自定义着色的唯一选项是:
"editor.tokenColorCustomizations": {
"[Atom One Dark]": {
"comments": "#FF0000" // only 6 color-customizable
},
"workbench.colorCustomizations": {
"statusBar.background": "#666666",
"panel.background": "#555555",
"sideBar.background": "#444444"
},
},
有没有办法为这些类型的东西设置自定义颜色?一个用于注释,用于字符串(内部"string"
)。我相信使用正则表达式的其他东西应该可以做类似的事情。提前致谢。
解决方案
搜索tokenColorCustomizations
andtextMateRules
你会发现你可以做这样的事情(见colorizing with textmate):
"editor.tokenColorCustomizations": {
"textMateRules": [
{
// works for a language that recognizes backticks as string templates
"scope": "string.template",
"settings": {
"foreground": "#FF0000"
}
},
{
"scope": "punctuation.definition.template-expression.begin, punctuation.definition.template-expression.end",
"settings": {
"foreground": "#F0F"
}
},
]
}
使用Inspect TM Scopes...
命令面板中的命令。所以我使用该命令在模板文字内单击并获得string.template.js.jsx
范围。但这并没有改变 ${someVar} 所以我检查了那个范围并看到了 variable.other.readwrite.js.jsx
额外的范围参数 - 仍在努力将这种变量与其他变量隔离开来。
编辑:如果string.template
语言将反引号视为字符串模板,则应仅使用 来处理更多文件类型。
您还可以更改fontStyle
设置。这里有一些关于使用TM Scopes
命令的答案。
推荐阅读
- c# - 内容控件的导出-导入内容后的 Microsoft Word 文档编号更改
- matplotlib - Tkinter 中 Matplotlib 图的滚动条
- python - 周围有非递归的 dataclass.astuple 吗?
- kubernetes - 如何使用 helm 安装 Traefik v2 ingress daemonset?
- reactjs - 从详细面板材料表发送行数据时出错
- python - 从烧瓶函数获取返回值到另一个 python 文件(从非烧瓶 python 文件调用烧瓶函数)
- sql - 获取要在表连接选择中使用的动态临时表的列名
- python - 如何在 on_message 函数中发送消息?
- c++ - CUDA 编译器无法编译简单的测试程序
- pyspark - 胶水作业将多个分区写入同一个文件