增強型著色
當啟用 IntelliSense 時,Visual Studio Code C/C++ 擴充套件現在支援語義著色。增強型著色的使用由 C_Cpp.enhancedColorization 設定控制。此設定預設啟用。
"C_Cpp.enhancedColorization": "enabled"
主題
可以使用 VS Code 中現有對主題和顏色自定義的支援來關聯顏色。有關更多資訊,請參閱VS Code 主題文件。
顏色與語義標記以及TextMate 作用域相關聯。
C/C++ 主題擴充套件
我們建立了一組 VS Code 主題,這些主題與 Visual Studio 中的預設淺色和深色主題非常相似,幷包含語義標記的顏色。這些主題可以在此處找到。
IntelliSense 標記和作用域
標記 | 語義標記名稱 | 回退 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 |
引數 | 引數 | 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"
}
}
}
}