我能找到的在 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
和 textMateRules
,您会发现您可以这样做(参见 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
命令的答案。
关于visual-studio-code - 在 VSCode 中自定义 `backquotes` 内的文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52785989/