Different colors for same type of variables


My question is simple. Say I write the following in my atom editor:

double position=1., kT=2.;

Atom makes position white, just like any other normal variable. However, kT is colored orange! I haven’t changed any default theme settings or anything. Does anyone know why? Is kT something special in atom? Some other variable names also trigger the color orange.


What language are you working with?

No, because Atom doesn’t know anything about code. It’s the specific language package that determines how code is marked for highlighting.


Out of curiousity: Does it also happen when you write your code like this?

double position=1.;
double kT=2.;


To push this conversation forward …

I am of the opinion this behaviour was part of the original grammar ported from Textmate. Personally I would expect the small capital k to mark a constant. This would mean the colouring is sort-of correct.

Not all themes colour this way either which is another interesting thing.

@Wliu - do you have any thoughts to share?

Exploring the syntax identification ->








C++, using “one-dark-syntax” theme


Yes, there are some words that get highlighted. Like int N_t, N_t is cyan color!!


This is great work, this really explains my question well.



There must be a reason why the choice was made to have that particular combination identified as it is. The best would be to understand to which standard this is based on, in my opinion. This is not a bug - this is intentional.

Sorry I will not be able to help you further on this matter. It has been a very long while since I coded anything in C / C++.

If you feel it is something that requires attention, consider creating an issue in the Github project where the C-language package lives.



the javascript language does something similar. It turns anything in all caps to that orange/yellow color. The colors are based on naming conventions.

a naming standard in c is to start constants with a k
and i’m guessing it’s a standard to start static variables with an s

this is the code straight from the language cson. As you can see it defines constants, globals, and statics.

    # Common naming idiom for C constants: "kConstantVariable"
    'match': '\\bk[A-Z]\\w*\\b'
    'name': 'constant.other.variable.mac-classic.c'
    'match': '\\bg[A-Z]\\w*\\b'
    'name': 'variable.other.readwrite.global.mac-classic.c'
    'match': '\\bs[A-Z]\\w*\\b'
    'name': 'variable.other.readwrite.static.mac-classic.c'