Make Sense of Your Variables at a Glance with Semantic Highlighting

Paul Everitt

Let’s say you have a really dense function or method, with lots of arguments passed in and lots of local variables. Syntax highlighting helps some, but can PyCharm do more?

In 2017.1, PyCharm ships with “semantic highlighting” available as a preference. What is it, what problem does it solve, and how do I use it? Let’s take a look.

It’s So Noisy

Sometimes you have really, really big functions. Not in your codebase, of course, because you are tidy. But hypothetically, you encounter this in a library:


PyCharm helps, of course. Syntax highlighting sorts out the reserved words and different kinds of symbols: bold for keywords, gray for unneeded, yellow means suggestion, green for string literals. But that doesn’t help you focus on the parameter “namespaces”. Clicking on a specific symbol highlights it for the rest of the file:


That kind of works, but not only do you have to perform an action for each symbol you want to focus on, it also moves your cursor. It’s a solution to a different problem.

How can my tool help me scan this Python code without much effort or distraction?

IntelliJ Got It

As you likely know, PyCharm and our other IDEs are built atop the IntelliJ IDEA platform. In November, IntelliJ landed an experimental cut of “semantic highlighting”:

“Semantic Highlighting, previously introduced in KDevelop and some other IDEs, is now available in IntelliJ IDEA. It extends the standard syntax highlighting with unique colors for each parameter and local variable.”

It wasn’t available in the IDEs, but you could manually enable it via a developer preference. Here’s a quick IntelliJ video describing the problem and how semantic highlighting helps.

With PyCharm 2017.1, the engine is now available to be turned on in preferences. Let’s see it in action.

Crank Up the Signal

Blah blah blah, what does it look like?


Our noisy function now has some help. PyCharm uses semantic highlighting to assign a different color to each parameter and local variable: the “namespaces” parameter is now a certain shade of green. You can then let color help you scan through the function to track the variable, with no distracting action to isolate one of them or switch focus to another.

To turn on semantic highlighting in your project, on a per-font-scheme basis, visit the Editor -> Colors & Fonts -> Language Defaults preference:


Your Colors Make Me Sad

The default color scheme might not work for you. Some folks have visual issues with red and green, for example. Some might have contrast issues in their theme or workspace. Others might simply hate #114D77 (we’ve all been there.)

If you make IDEs for long enough, you learn self-defense, and that means shipping a flexible means of customization:


The pickers let you assign base colors then gradients to tailor a wide number of local symbols to your needs and taste.

Learn More

PyCharm’s goal is to help you be a badass Python developer, and hopefully our use of semantic highlighting helps you make sense of dense code. We’re still working on the idea itself as well as the implementation, so feel free to follow along in our bug tracker across all our products, since this isn’t a PyCharm-specific feature.

And as usual, if you have any quick questions, drop us a note in the blog comments.

Comments below can no longer be edited.

32 Responses to Make Sense of Your Variables at a Glance with Semantic Highlighting

  1. bronsen says:

    January 19, 2017

    how about adding a screenshot that shows what the code looks like after enabling “semantic highlighting”?

    • bronsen says:

      January 19, 2017

      Excellent, there it is 🙂

      /me goes to reboot browser

      • Paul Everitt says:

        January 21, 2017

        I’d be interested in your thoughts on the utility of this feature, after you’ve used it a while. I went through this cycle: “Oh wow, cool! Hmm, all the colors look the same. Oh, wait, now it’s making sense, nice!”

  2. Jason says:

    January 25, 2017

    Your colors do make me sad. Can’t see reds very well. Thanks for including a method to change the defaults. Going to save me a ton of time

    • Paul Everitt says:

      January 25, 2017

      Thanks for letting us know. If you do find a set of colors that you think is better for us, let us know.

  3. Jeremiah says:

    February 10, 2017

    I’m using Pycharm 2016.3.2, but feeling no difference after enabling Sematic in preferences. Colors didn’t change. Is this a bug?

    • Ernst Haagsman says:

      February 10, 2017

      Semantic highlighting is a new feature in PyCharm 2017.1, if you’d like to check it out, get an Early Access Program (EAP) version from

  4. Jungyu Kim says:

    March 27, 2017

    True / False / None color is changed… How do i get reset???????

    • Paul Everitt says:

      March 27, 2017

      Semantic highlighting controls the color of variable names, not values.

      • Samuel Bronson says:

        October 14, 2019

        … you mean those aren’t variable names?

        • aklfj says:

          November 15, 2019

          True and False are value

  5. Christopher Rucinski says:

    April 13, 2017

    How do the IDE figure out which color to give each variable?

    I have created a color scheme plugin and I would like to see if I should enable some presets for my users, but I cannot determine how each variable is given its color. It appears to be random in my available code. Once I figure this out, I can try to find a good color combination that works with my existing colors.

    However, If the variables are given colors in a somewhat random manner, then I would rather it not be enabled by default in my color scheme plugin.

    One thing I thought might have been available in this feature was that it could indicate to the user if I method had too many parameters (i.e. set color 1 through 3 as a single color gradient with color 4 through 5 as a red gradient)). However, this doesn’t seem to be the case for this feature.

    • Paul Everitt says:

      April 13, 2017

      Here’s the help page for configuring colors for each variable.

      • Christopher Rucinski says:

        April 13, 2017

        I know how to configure the colors. That wasn’t what I was trying to figure out.

        I am more or less looking for the algorithm, or a way for me to look at some code, and given color #1 – #5, I can reasonable guess what color the IDE will give a specific variable.

        Based on my own code and the code in the attached picture in the “Crank Up the Signal” section, I cannot figure out any type of algorithm. It all seems random at which color a specific variable will get.

      • Christopher Rucinski says:

        April 16, 2017

        I look into the RainbowHighlighting code files but wasn’t able to glean too much knowledge into how the colors for a specific variable was decided, but I also checked on other IDE’s have implemented semantic highlighting.

        I have heard that most are decided based on a hash of the variable name. A few have referenced sorting the variables by name and spreading the colors out based on that. Regardless, both of these would appear to randomly select a color for each variable.

        Now, this does have its benefit for developers with specific types of color schemes. This type of implementation should stay as is; however, it seems like a deterministic coloring mechanism could be devised to fill in different types of niches.

        A use case for a deterministic coloring mechanism would be to allow developers the ability to see if their methods have too many parameters (color #1 – 3 be white to gray, color #4 – 5 be red). If a method has 5+ parameters, then the last ones will be red, but the first ones will be white. It is deterministic because I know the 1st parameter will be white because it is the 1st parameter, and if there are too many parameters then I know the last few will be red, but if there are only three parameters, then I know it will not be red but gray.

  6. izhangzhihao says:

    October 8, 2017

    Hi, Can I only turn this ‘semantic high lighting’ option for python , because I am also work with java/scala/kotlin and i don’t want other langs been high lighting like this. Any idea? Or how can I create a detached plugin which can only ‘semantic high lighting’ python only, I tried to see source code of intellij, but I am got losted. Anyway thanks for your work!

    • Semyon Proshev says:

      October 9, 2017

      Hello! There is no better way to achieve this than enable semantic highlighting in language defaults (File – Settings – Editor – Color Scheme – Language Defaults) and disable it for every undesirable language (e.g. File – Settings – Color Scheme – Java).

      I’ve created an issue for your request:

  7. Denis Matei says:

    July 18, 2018

    I tried all of this but my code editor looks monotone.
    It doesn’t give colours to the functions.

    • Paul Everitt says:

      July 18, 2018

      What theme are you using?

  8. Gee says:

    October 25, 2018

    This does not work for Ruby on RubyMine 2018.2.4.

    I have it working in PyCharm, but the Color Scheme for Python deliberately has the option for semantic highlighting. I do not see the same option for Ruby.

    • Paul Everitt says:

      October 25, 2018

      Right, this is something that each IDE manages individually for its languages.

      • Gee says:

        October 26, 2018

        I see, thought this was a shared thing between them since it was an option under ‘Language defaults’. Guessing that RubyMine doesn’t have it then.

        Just noticed I’m in the PyCharm’s support section as well, I’ll go look in the RubyMine’s support then.

  9. Sew For says:

    January 9, 2019

    I tried all of this but my code editor looks monotone.
    It doesn’t give colours to the functions.

    I use Genesis theme

    help me!

    • Paul Everitt says:

      January 9, 2019

      Can you see if it works in a built-in theme? If so, then it sounds like a bug report to the Genesis theme issue tracker.

  10. Chojrak Tchórzliwy says:

    February 22, 2019

    What font is on the screenshots? Fira Code? Don’t think so.

    • Paul Everitt says:

      February 22, 2019

      Not sure what I used for those (2 years ago.)

  11. 6best says:

    March 1, 2019

    I tried all of this but my code editor looks monotone.
    It doesn’t give colours to the functions.

    I use Thrive theme

    help me!

    • Paul Everitt says:

      March 1, 2019

      The theme has to support it. Try switching temporarily to a built-in theme and see if it works.

  12. Ann Moody says:

    April 20, 2019

    Hi Paul,
    Thanks a lot. Though I couldn’t update in the beginning, I switched to built-in-theme and it is great!

  13. Prayansh says:

    May 17, 2019

    Is there a way to toggle this setting on the fly. Feels like a good addendum to the original feature.

  14. Justin Brown says:

    August 6, 2019

    I really love this feature, and I’m glad this article exists because for the life of me I will never remember what the feature is called. So when I have to enable it on a fresh install, I always have to look up this page lol


Subscribe for updates