Sublime Forum

Source scope .h files

#1

Hello everyone. I apologize if this was already answered somewhere, but couldn’t find anything :slightly_smiling:

I’m currently writing code in C and I wanted to add to my C.sublime-build file a variant to build .h files aswell, but couldn’t do it.

I tried to use both
"selector" : "source.c, source.h"
and
"selector" : "source.h"
in both variant and “main” build.

Any hint? :slightly_smiling:
Thanks

0 Likes

#2

In the default C/C++ support provided with Sublime, there isn’t a separate scope for header files; they’re scoped the same as C++ unless you’ve used View > Syntax > Open all with current extension as... while editing a .h file to change it to something else (i.e. C).

This is because the default C++ package has an extensions setting that ensures that it gets priority over .h files.

So the selector you want is source.c++ unless you’ve done something to override the override (as it were).

As an aside, in this sort of situation you can use Tools > Developer > Show Scope Name from the menu (or it’s associated key binding) while you’re editing a file to determine the scope at the current cursor location.

3 Likes

#3

Thanks a lot, gotcha :blush:

0 Likes