首先,我知道这个帖子已经有一年多的历史了,但是我在没有改变 Dark + 主题的情况下也在搜索同样的东西,所以我把它们放到了 setings.json 的 vs code 中,它可能不是最漂亮的,但是它甚至可以在任何你选择的没有斜体的主题上工作,如果你想删除它,只需要把它放到注释中,如果你以后想改变它,我已经把颜色放到注释中了!
当你为 VS 代码定义一种字体时(比如 OP 的操作符 Mono) ,所有的东西都是以这种字体呈现的。为了实现 OP 图像中的外观,您需要对某些元素应用不同的字体样式(斜体/粗体)。此外,如果你的字体有一个明显不同的斜体风格(例如操作员 Mono 有草书连字) ,你会得到一个类似的外观 OP 的图像。
VS Code 使用 TextMate 语法语法来定义如何呈现代码。您可以参考 官方文件以获得进一步的清晰度。在 setings.json 中,仍然可以通过修改 editor.tokenColorCustomizations下的 textMateRules来覆盖当前主题的字体样式。
你可在此找到以下样本:
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [
// the following elements will be in italic
// (=Fira Code iScript)
"comment",
"keyword.control.import.js", // import
"keyword.control.export.js", // export
"keyword.control.from.js", // from
// "constant", // String, Number, Boolean…, this, super
"storage.modifier", // static keyword
"storage.type.class", // class keyword
"storage.type.php", // typehints in methods keyword
"keyword.other.new.php", // new
"entity.other.attribute-name", // html attributes
"fenced_code.block.language.markdown" // markdown language modifier
],
"settings": {
"fontStyle": "italic"
}
},
{
"scope": [
// the following elements will be displayed in bold
"entity.name.type.class" // class names
],
"settings": {
"fontStyle": "bold"
}
},
{
"scope": [
// the following elements will be displayed in bold and italic
"entity.name.section.markdown" // markdown headlines
],
"settings": {
"fontStyle": "italic bold"
}
},
{
"scope": [
// the following elements 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",
"comment.block",
"entity.other.attribute-name.class.css"
],
"settings": {
"fontStyle": ""
}
}
]
}