Using Scope-Based Code Highlighting

One of not so well-known features of IntelliJ IDEA is an ability to differently highlight certain scopes in code editor.

To use it, open the Settings dialog, under IDE Settings expand Editor, then expand Colors & Fonts, and select Scope Based preferences. You will see a list of predefined scopes, and the Edit Scopes button that lets you easily create your own.

Each scope is assigned a distinct color/font scheme — just like different language elements in Java, which makes it easy to distinguish from other code in the editor.

In the following example, it is used to quickly differentiate between real testing code and JUnit Classes (pattern: lib:org.junit..*):

Other use cases include highlighting of, for example, third-party framework code, distinguishing normal code from assertions, etc.

This entry was posted in New Features and tagged . Bookmark the permalink.

3 Responses to Using Scope-Based Code Highlighting

  1. Eugene Kirpichov says:

    Thanks, this is awesome. I’ll definitely be using this feature a lot.
    Why not include it into the Tips at startup?

  2. Some other highlightings that I’ve found useful are “Reassigned local variable”, “Reassigned parameter”, “Interface”, “Abstract class” and “Type parameter”. My color choices are at

  3. RobB says:

    I was just looking for a way to discriminate between project and library code and found this. Perfect.

Leave a Reply

Your email address will not be published. Required fields are marked *