VS代碼允許用戶自定義語法高亮顏色特定的語法在settings.json。最靈活的方法是使用"textMateRules"屬性,其格式如下:
"editor.tokenColorCustomizations": {
"textMateRules": [{
"scope": ["keyword.other", "keyword.control"],
"settings": {
"foreground": "#FF0000",
"fontStyle": "bold"
}
}]
}
上述代碼段的問題在于它將所選樣式應用于任一keyword.otherORkeyword.control范圍。是否可以設計textMateRules需要keyword.otherANDkeyword.control范圍的配置?
uj5u.com熱心網友回復:
另見https://stackoverflow.com/a/64836542/836330
使用這個表格:
"editor.tokenColorCustomizations": {
"textMateRules": [{
"scope": "keyword.other keyword.control",
"settings": {
"foreground": "#FF0000",
"fontStyle": "bold"
}
}]
}
"scope": "keyword.other keyword.control", // note separated by a space, one string
此表格需要同時存在兩個范圍才能應用。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/374861.html
