gpt4 book ai didi

visual-studio-code - 如何在 VS Code 中自定义多个主题的 textMateRules?

转载 作者:行者123 更新时间:2023-12-01 17:48:57 24 4
gpt4 key购买 nike

VS Code中,我想自定义一些textMateRules多个主题相同。例如,两者都为 Atom One DarkDefault Dark+但在不影响任何其他主题的情况下,我想制作 keyword s 斜体。我可以通过为每个主题分别复制相同的设置两次来实现此目的,如下所示

  "editor.tokenColorCustomizations": {
"[Atom One Dark]": {
"textMateRules": [
{
"scope": [ "keyword" ],
"settings": { "fontStyle": "italic" }
}
]
},
"[Default Dark+]": {
"textMateRules": [
{
"scope": [ "keyword" ],
"settings": { "fontStyle": "italic" }
}
]
}
}

我怎样才能只需要为两个主题设置一次,而不重复规则,特别是如果多个主题有很多相同的规则?类似于下面的内容(但是不起作用)

  "editor.tokenColorCustomizations": {
"[Atom One Dark] [Default Dark+]": {
"textMateRules": [
{
"scope": [ "keyword" ],
"settings": { "fontStyle": "italic" }
}
]
}
}

最佳答案

来自this Github page

首先将此代码复制到用户设置。

"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [
//following will be in italic (=FlottFlott)
"comment",
"entity.name.type.class", //class names
"keyword", //import, export, return…
"constant", //String, Number, Boolean…, this, super
"storage.modifier", //static keyword
"storage.type.class.js", //class keyword
],
"settings": {
"fontStyle": "italic"
}
},
{
"scope": [
//following will be excluded from italics (VSCode has some defaults for italics)
"invalid",
"keyword.operator",
"constant.numeric.css",
"keyword.other.unit.px.css",
"constant.numeric.decimal.js",
"constant.numeric.json"
],
"settings": {
"fontStyle": ""
}
}
]
}

现在仔细观察,在 textMateRules 中您必须定义一个范围。在范围数组中,你必须提到你要修改哪些选项,然后,在同一范围的设置数组中你可以添加你的样式,例如你想添加fontStyle italic。像这样。

"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [
//following will be in italic (=FlottFlott)
"comment",
"entity.name.type.class", //class names
"keyword", //import, export, return…
"constant", //String, Number, Boolean…, this, super
"storage.modifier", //static keyword
"storage.type.class.js", //class keyword
],
"settings": {
"fontStyle": "italic"
}
}
]
}

关于visual-studio-code - 如何在 VS Code 中自定义多个主题的 textMateRules?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55054156/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com