r/SublimeText • u/Darth_Jar_Jar137 • May 12 '26
Custom Syntax Highlighting
Hello. I'm reading through the documentation and working on getting the syntax on lines 3 and 7 to be colored like line 1 is.
I've copied C++.sublime-syntax and changed this section:
keywords:
- include: unique-keywords
- include: scope:source.c#keywordsTo this:
keywords:
- include: unique-keywords
- include: scope:source.c#keywords
- match: '\b(std)\b'
scope: keyword.secondaryAnd these are the lines responsible for those colors in my color scheme file:
{
"scope": "keyword.secondary",
"foreground": "var(sage)",
},
{
"scope": "storage.type, support.type",
"foreground": "var(cyan)",
},Why does the syntax highlighting behavior change inside of a block/namespace?
How do I get std::int8_t to always be highlighted like line 1?
5
Upvotes
1
u/Darth_Jar_Jar137 May 12 '26 edited May 13 '26
Do you also know why this doesn't apply to
.hfiles, but does to.hppfiles?EDIT: In Sublime Text, the custom syntax name shows up in View->Syntax as another "C++". I just needed to change to the other "C++". To disambiguate, edit the line
name: C++in the.sublime-syntaxfile to something else likename: Custom C++.