Sublime Forum

C++ need to highlight 'namepace' keyword

#1

I use Sublime Text to write c++. One thing that annoys me is that the ‘namespace’ keyword does not get syntax highlighted (appears as white text - see image). I have tried messing around with the ‘c++.tmlanguage’ file, but have not had any success. Can anyone help? thank you.

0 Likes

#2

i just highlight the first namespace like this
geekpics.net/rFO
it changed in[c++|c.tmlanguage ]file line:49. add [namespace].
the second namespace i think you need do a file like [struct.sublime-snippet],but i don’t know how to use this file.
hope this can help you some.

0 Likes

#3

I have been looking at this myself, looking for an easier fix for this. Here is what I found:

If you edit the C++.tmLanguage file, on about line 370, you’ll see something that looks like this:

				<key>begin</key>
				<string>\b(class|struct)\s+([_A-Za-z][_A-Za-z0-9]*\b)</string>
				<key>beginCaptures</key>

This seems to be what causes the highlight on words after key words like struct or class, which is the exact same syntax I wanted after the word using, so that using namespace would be highlighted according to my theme. So, I just added a |using to that, making it look like this:

				<key>begin</key>
				<string>\b(class|struct|using)\s+([_A-Za-z][_A-Za-z0-9]*\b)</string>
				<key>beginCaptures</key>

This did the trick for me. Have fun.

0 Likes