我试图覆盖VS Code中的默认语法颜色。特别要代替#a31515
默认主题“ Light(Visual Studio)”中的#036A07
(红色)颜色,我想查看(绿色)颜色。
为此,editor.tokenColorCustomizations
我在用户设置settings.json
文件中更改了以下默认值:
"editor.tokenColorCustomizations": null
至:
"editor.tokenColorCustomizations": {
"markup.deleted": "#036A07",
"meta.preprocessor.string": "#036A07",
"string": "#036A07",
"entity.name.operator.custom-literal.string": "#036A07",
"meta.embedded.assembly": "#036A07"
}
我保存了settings.json
文件并重新启动了VS代码,但是在代码突出显示中没有看到任何更改(与以前相同的红色):
问题:我的代码有什么问题,正确的代码是什么?
从下面的@tHeSiD答案中,我创建了此代码,它起作用了:
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"name": "Single Quotes",
"scope": "string.quoted.single.python",
"settings": {
"fontStyle": "",
"foreground": "#036A07"
}
}]
}
仅针对特定主题进行设置:
"editor.tokenColorCustomizations": {
"[Visual Studio Light]": {
"textMateRules": [
{
"name": "Single Quotes",
"scope": "string.quoted.single.python",
"settings": {
"fontStyle": "",
"foreground": "#036A07"
}
}]
}
}
也可以不设置editor.semanticHighlighting.enabled
为false
您必须像这样添加每个作用域定义。
要获得所需的范围,请使用命令面板(CTRL SHIFT P),然后选择 Developer: Inspect Editor Tokens and Scopes
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"name": "Deleted",
"scope": "markup.deleted",
"settings": {
"fontStyle": "italic",
"foreground": "#036A07"
}
},
{
"name": "Strings",
"scope": "meta.preprocessor.string",
"settings": {
"fontStyle": "italic"
}
},
{
"name": "ThisIsJustANameForReference",
//You can use coma separated scopes to group them into one
"scope": "entity.name.operator.custom-literal.string, meta.embedded.assembly",
"settings": {
"foreground": "#036A07"
}
},
]
},
这些是文本规则,您必须禁用“语义突出显示”才能起作用。为此添加"editor.semanticHighlighting.enabled": false
如果您想通过语义突出显示为所有内容着色,则必须使用类似的方法。
"semanticTokenColors": {
"namespace": "#ffffff",
"type": "#ffffff",
"struct": "#ffffff",
"class": "#ffffff",
"class.readonly": {
"foreground": "#ffffff",
"fontStyle": "bold italic"
},
"*.declaration" : {
"fontStyle": "bold"
},
"*.readonly" : "#ffffff",
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句