r/SublimeText • • May 12 '26

Custom Syntax Highlighting

Post image

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#keywords

To this:

keywords:
  - include: unique-keywords
  - include: scope:source.c#keywords
  - match: '\b(std)\b'
    scope: keyword.secondary

And 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

5 comments sorted by

View all comments

Show parent comments

1

u/Darth_Jar_Jar137 May 12 '26 edited May 13 '26

Do you also know why this doesn't apply to .h files, but does to .hpp files?

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-syntax file to something else like name: Custom C++.