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?
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?
Share Improve this question edited Feb 3 at 13:29 Bri Bri asked Feb 3 at 4:52 Bri BriBri Bri 2,0823 gold badges24 silver badges65 bronze badges 7 | Show 2 more comments1 Answer
Reset to default 2Just 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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745248978a4618559.html
char
,unsigned
andlong
are keywords.UInt8
andMyStruct
are not. – 3CxEZiVlQ Commented Feb 3 at 5:05uin8_t
(Standard-mandated type but not a keyword) get special highlighting? If not you might have to work very hard. – user4581301 Commented Feb 3 at 5:07stdint.h
such asuint8_t
do get special highlighting. – Bri Bri Commented Feb 3 at 5:08_MyStruct
) are reserved and should not be defined by your code. – Some programmer dude Commented Feb 3 at 5:51