Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm using Gedit to write C++ code, and have applied my custom syntax colour scheme which works (and looks) great with the exception of the string type, which, for both my custom style and the various bundled styles, is the same colour as the rest of the text. I am able to access the xml files that contain the style settings and there is no setting for defining the colour of string. Does anyone know how I can do this?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Ok I've found the solution. It's not in the style file, but deeper into the Gedit infrastructure in the language definition file instead. These files are store in /usr/share/gtksourceview-2.0/language-specs/ and the file in question is cpp.lang. Look for the list enclosed called id = "keyword" and add to this list the entry <keyword>string</keyword>, save the file, and restart Gedit. Done.

share|improve this answer
1  
The string class was added in C++ and does not exist in C, so you probably shouldn't add it to the C file. Also the reason that it wasn't highlighted specially is that, unlike int or char, it's not a keyword - just the name of a class. –  sepp2k Oct 15 '10 at 15:03
    
I've taken your advice and moved the edit to cpp.lang instead and edited my response appropriately. I think this come down to personal taste, as string is indeed the name of a class, but the syntax is used in much the same way as other declarations, when I've posted code to Stack Overflow, string has been highlighted there, so like I said, personal preference. –  Chris Wilson Oct 15 '10 at 16:06
    
It's highlighted on stackoverflow because stackoverflow highlights all languages the same and in some languages string is a keyword. And I'm not saying you shouldn't highlight string (though I personally would find it inconsistent if string is highlighted, but e.g. vector is not) - I'm just explaining why gedit doesn't. –  sepp2k Oct 15 '10 at 16:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.