增強色彩化
Visual Studio Code C/C++ 擴充功能現在在啟用 IntelliSense 時支援語意色彩化。增強色彩化的使用由 C_Cpp.enhancedColorization 設定控制。此設定預設為啟用。
"C_Cpp.enhancedColorization": "enabled"
佈景主題
色彩可以使用 VS Code 中現有的佈景主題和色彩自訂支援來關聯。請參閱 VS Code 佈景主題文件 以取得更多資訊。
色彩與 語意語彙基元 以及 TextMate 範圍 相關聯。
C/C++ 佈景主題擴充功能
我們建立了一組 VS Code 佈景主題,與 Visual Studio 中的預設淺色和深色佈景主題非常相似,並包含語意語彙基元的色彩。這些佈景主題可以在這裡找到。
IntelliSense 語彙基元和範圍
語彙基元 | 語意語彙基元名稱 | Fallback TextMate 範圍 |
---|---|---|
類別範本 | templateType | entity.name.type.class.templated |
列舉值 | enumMember | variable.other.enummember |
事件 (C++/CLI) | event | variable.other.event |
函式 | function | entity.name.function |
函式範本 | templateFunction | entity.name.function.templated |
泛型型別 (C++/CLI) | genericType | entity.name.type.class.generic |
全域變數 | variable.global | variable.other.global |
標籤 | label | entity.name.label |
區域變數 | variable.local | variable.other.local |
巨集 | macro | entity.name.function.preprocessor |
成員欄位 | property | variable.other.property |
成員函式 | method | entity.name.function.member |
命名空間 | namespace | entity.name.namespace |
New / Delete | newOperator | keyword.operator.new |
運算子多載函式 | operatorOverload | entity.name.function.operator |
運算子多載成員 | memberOperatorOverload | entity.name.function.operator.member |
參數 | parameter | variable.parameter |
屬性 (C++/CLI) | cliProperty | variable.other.property.cli |
參考型別 (C++/CLI) | referenceType | entity.name.type.class.reference |
靜態成員欄位 | property.static | variable.other.property.static |
靜態成員函式 | method.static | entity.name.function.member.static |
型別 | type | entity.name.type |
使用者定義常值 - 數字 | numberLiteral | entity.name.operator.custom-literal.number |
使用者定義常值 - 原始 | customLiteral | entity.name.operator.custom-literal |
使用者定義常值 - 字串 | stringLiteral | entity.name.operator.custom-literal.string |
實值型別 (C++/CLI) | valueType | entity.name.type.class.value |
在設定中自訂色彩
色彩也可以全域覆寫,在設定中
"editor.semanticTokenColorCustomizations": {
"rules": {
"templateType": {
"foreground": "#ff0000",
"fontStyle": "italic bold underline"
}
}
}
或者,在每個佈景主題基礎上覆寫
"editor.semanticTokenColorCustomizations": {
"[Visual Studio Dark]": {
"rules": {
"templateType": {
"foreground": "#ff0000",
"fontStyle": "italic bold underline"
}
}
}
}