I have a C project that has various typedef'd types such as:
typedef uint8_t UInt8;
typedef struct MyStruct_ {
...
} MyStruct;
However, unlike built-in types, they don't get correct syntax highlighting:
Note that MyStruct
and UInt8
are not colored the same as char
and unsigned long
.
How can I fix this?
Just open your settings.json
then add editor.semanticHighlighting.enabled
to true
and set rules for specific types
like I did here for all types. For example you can change color of typedef
as well like I did here for type
. Find the hex code of the color you want may be by using any color picker tool.
{
"editor.semanticHighlighting.enabled": true,
"editor.semanticTokenColorCustomizations":
{
"rules":
{
"type":
{
"foreground": "#6c9ada"
}
}
}
}
Note: I didn't look for the exact color just close enough.
Here MyStruct
type now in that #6c9ada
color close to that default char
type.