본문으로 건너뛰기

Enhanced colorization

The Visual Studio Code C/C++ extension now supports semantic colorization, when IntelliSense is enabled. Use of enhanced colorization is controlled by the C_Cpp.enhancedColorization setting. This setting is enabled by default.

"C_Cpp.enhancedColorization": "enabled"

Themes

Colors can be associated using the existing support for theming and color customization in VS Code. See the VS Code Themes documentation for more information.

Colors are associated with semantic tokens as well as TextMate scopes.

C/C++ Themes Extension

We've created a set of VS Code themes that closely resemble the default Light and Dark themes in Visual Studio, and include colors for semantic tokens. These themes can be found here.

IntelliSense Tokens and Scopes

TokenSemantic Token nameFallback TextMate Scope
Class TemplatetemplateTypeentity.name.type.class.templated
EnumeratorenumMembervariable.other.enummember
Event (C++/CLI)eventvariable.other.event
Functionfunctionentity.name.function
Function TemplatetemplateFunctionentity.name.function.templated
Generic Type (C++/CLI)genericTypeentity.name.type.class.generic
Global Variablevariable.globalvariable.other.global
Labellabelentity.name.label
Local Variablevariable.localvariable.other.local
Macromacroentity.name.function.preprocessor
Member Fieldpropertyvariable.other.property
Member Functionmethodentity.name.function.member
Namespacenamespaceentity.name.namespace
New / DeletenewOperatorkeyword.operator.new
Operator Overload FunctionoperatorOverloadentity.name.function.operator
Operator Overload MembermemberOperatorOverloadentity.name.function.operator.member
Parameterparametervariable.parameter
Property (C++/CLI)cliPropertyvariable.other.property.cli
Reference Type (C++/CLI)referenceTypeentity.name.type.class.reference
Static Member Fieldproperty.staticvariable.other.property.static
Static Member Functionmethod.staticentity.name.function.member.static
Typetypeentity.name.type
User-Defined Literal - NumbernumberLiteralentity.name.operator.custom-literal.number
User-Defined Literal - RawcustomLiteralentity.name.operator.custom-literal
User-Defined Literal - StringstringLiteralentity.name.operator.custom-literal.string
Value Type (C++/CLI)valueTypeentity.name.type.class.value

Customizing Colors in Settings

Colors can also be overridden globally, in settings:

    "editor.semanticTokenColorCustomizations": {
"rules": {
"templateType": {
"foreground": "#ff0000",
"fontStyle": "italic bold underline"
}
}
}

Or, overridden on a per-theme basis:

    "editor.semanticTokenColorCustomizations": {
"[Visual Studio Dark]": {
"rules": {
"templateType": {
"foreground": "#ff0000",
"fontStyle": "italic bold underline"
}
}
}
}