Colorful code: how color helps with code

    As a programmer working with different languages ​​and on different platforms, at one point in time I encountered one unexpected problem: to conduct a review or write my own code, I had to spend a lot of time switching between IDE and languages. There was a need for some kind of tool that would help me do this more efficiently and without loss of concentration. And suddenly color came to my aid . And I want to share this little life hack.

    All IDEs have such a wonderful feature as syntax highlighting. Everything would be fine, but everywhere it is different and even within the same development environment it may differ for different languages. But the main thing is that the backlight does not help often enough (personally to me) to distinguish structural components, such as methods, variables, classes, structures ... They are usually drawn in the same color and I decided to choose my color scheme that would perform the differentiation function not only syntactic elements (such as keywords), but also semantic (classes, structures, methods and functions).

    Darkula color scheme example in Android Studio
    In principle, only keywords and constants are highlighted.


    The concept began with the Ciapre color scheme for Xcode. It initially (and it is worth admitting that the IDE itself) provides such a semantic division precisely with color. Flat colors do not hurt the eyes and are quite different for different types of semantic elements.
    The result is approximately the following separation:

    • Keywords - Red
    • Reference Types (Classes) - Yellow
    • Interfaces - Orange
    • Value Types - Purple
    • Constant values ​​are also purple, but brighter
    • Methods and functions - blue (external, from packages / modules - a little brighter)
    • Fields and Type Properties - Green

    After transferring to different IDEs, the following happened (yes, yes, I know the first reaction - “what kind of sour stuff” :-)):

    • Swift (Xcode)
      In Xcode, there are problems with interfaces (in terms of separation from classes), they are considered as a reference type and are also displayed in yellow.

    • Kotlin (Android Studio) (you can compare with the example above - darkula)
      In Kotlin there are all kinds of qualifiers and labels, there is also a separate color for them

    • Java (Android Studio)

    • C # (Visual Studio)
      There are namespaces in sharpe, a separate color for them. Well, the studio also saddens that there is no clear semantic separation in the settings (class field, method, etc.). ReSharper helps me with this.


    Of the additional bonuses - vision allows you to immediately find oddities already at the level of color perception without even reading the text. If I know that there should be an interface, then I will see that there is not enough orange color where I expect it (for example, a type corresponding to the interface can be written and everything seems to be valid, but not).

    Actually that's all :)

    For those who want to apply color schemes

    Good and beautiful code to everyone!

    Also popular now: