Search code examples
syntax-highlighting

what do the different GitHub code colors mean?


Is someone able to tell me what the different GitHub code colors mean? In the image below I have mix of red, orange, white and blue. Some of them I can probably guess at but I haven't been able to find transparent information on this, or at least I'm not searching the correct terms.

Code colrs


Solution

  • This is a feature called syntax highlighting. It helps developers to code because every color has its "meaning". Most code editors and services which display code have this feature, it's not a Github-only thing.

    Themes

    Often you have the choice of different themes, in which the code gets presented. These are just color palettes in which color has a meaning. Most developers have some favorite themes, especially light or dark themes.

    But different themes also have different colors for keywords, types and variables. So you can identify the code parts faster, than just black text on white background.

    Explanation of colors:

    • red: keywords
    • blue: strings, numbers, operators
    • white: variables
    • gray: comments
    • orange: classes