Using Scope-Based Code Highlighting

May 10th, 2009 by yannc76

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.

Tags: , , ,

2 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. Esko Luontola Says:

    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 http://github.com/orfjackal/idea-config/tree/idea81/colors

Leave a Reply