Imagine a bacon-wrapped Ferrari. Still not better than our free technical reports.
See all our reports

RebelRant: Syntax highlighters should emphasize definitions, not keywords and boilerplate

Many syntax highlighters have at some point made a wrong choice about a simple aspect of how they do syntax coloring and present code: they make keywords bold and emphasize the wrong thing – the boilerplate instead of the intentional code. This applies to many language IDEs, text editors and other syntax highlighters, but I’m mostly focusing on Java IDEs in this post, which have more information about code than a simple highlighter. Both Eclipse and IntelliJ IDEA have decided to make keywords bold, but NetBeans has a better default highlighting scheme.

I don’t know the exact original reason (probably from decades ago) for making keywords bold, but I imagine that it was desired to distinguish keywords from identifiers and to make all identifiers bold was out of the question, so keywords were made bold instead. And this style has remained common for years and years.

One day, while tinkering with a text editor, I realized that this choice puts the emphasis on completely wrong things – most keywords are more part of the boilerplate than the intention of the code, and should not be made to stand out.

What should be emphasized instead? Potentially a lot of different things depending on language, and perhaps highlighting should move more towards semantic, rather than syntactic. The highlighter could even be dynamic depending on what I’m currently interested in. But what if we keep it simple and mostly based on the syntax tree without further semantic analysis?

Emphasize definitions, not keywords!

A relatively simple scheme I can think of is to emphasize definitions instead of keywords: each definition with a new name entering scope should make the name bold, not the keywords (if any) that precede it! More specifically:

  • Make keywords not bold, except for return, break and continue, which jump out of a code block early and should still be emphasized a lot.
  • Keywords can be made italic instead, to keep distinction of keywords and symbols.
  • Annotations are meta-data like keywords and should follow similar style.
  • Make all the names of declarations/definitions bold

NetBeans already follows this scheme in general, so they deserve a shout out; however, both IntelliJ IDEA, Eclipse can be configured to follow this convention for Java at least to some degree. Here’s how for each IDE:


Open Preferences → Java → Editor → Syntax Coloring

  1. Change keyword and annotation styles
    1. Change “Keywords excluding ‘return’” from Bold to Italic
    2. Set “Annotations” to Italic
  2. Emphasize declarations
    1. Enable “Method declarations” and set to Bold
    2. Enable “Local variable declarations” and set to Bold


  • Class, field and type variable declarations can’t be configured.
  • Break and continue cannot be configured.
  • All keywords besides return use the same style e.g. int has the same style as public. Ideally int and other primitive types should get the same treatment as Class types.

Eclipse: Before & After

Unfortunately, these Eclipse preferences cannot be imported normally. But here’s the file with exported preferences (which I made for you to use!) anyway–you could also try setting these programmatically from a plug-in.

IntelliJ IDEA

Open Settings → Editor → Colors & Fonts, save scheme under new name:

  1. Change keyword and annotation styles
    1. Change “Keyword” from Bold to Italic (under Language Defaults)
    2. Set “Annotation name” to Italic (under Java)
  2. Emphasize declarations (under Java)
    1. Set “Anonymous class” to Bold
    2. Set “Method declaration” to Bold
    3. Set “Constructor declaration” to Bold
    4. Set “Instance Field” to not Bold


  • Unfortunately we cannot implement most of this scheme because declarations share the same style with uses.
  • Return, continue and break cannot be configured.
  • All keywords use the same style e.g. int has the same style as public. Ideally int and other primitive types should get the same treatment as Class types.
  • For better or worse, the bold font stands out much less than in Eclipse.

IntelliJ IDEA: Before & After

Download the exported NoBoldKeywords scheme


Open Options → Fonts & Colors → Syntax → Language: Java

  1. Change keyword and annotation styles
    1. Set “Annotation Use” to Italic
    2. Set “Keyword” to Italic
    3. Set “Keyword Directive” to Bold
  2. Emphasize more declarations
    1. Set “Field Declaration” to Bold
    2. Set “Local Variable Declaration” to Bold
    3. Set “Parameter Declaration” to Bold


  • All keywords besides ‘return’ are the same, e.g. int has the same style as public. Ideally int and other primitive types should get the same treatment as Class types.
  • Anonymous class declaration cannot be configured.

NetBeans: Before & After

Download the extported NoBoldKeywords scheme.

Final Words

Trying to apply this highlighting scheme in IntelliJ IDEA might not be worth it, but I recommend that Eclipse users try it out and see if they like it. You lucky NetBeans users out there basically have this scheme by default, but these additional tweaks can make it even better.

It would be really nice if IDEs would allow this kind of scheme to be fully-configured and even make it default. Forget the old habit of bold keywords!

Any comments or alternative scheme suggestions? Let me know in the comments or tweet at @t4ffer.

  • sander

    — for intellij and netbeans, “before” and “after” look exactly the same from more than 70 cm away :p
    — for eclipse, the original one actually looks cleaner for my eye. obviously, one reason is that everybody is just used to it, but maybe it is more than just that. my guess why emphasizing “public void” or “public static” gives a picture that is very easy to read and grasp with an eye: it puts a very strong emphasis on where the methods BEGIN, thus doing the best job in separating the independent units of code for the eye (that is, methods). but maybe it is just part of “old habits die hard”.

  • Erkki Lindpere

    I admit the screens show minor differences for NetBeans and IntelliJ — that’s due to how little was possible or had to be changed compared to defaults.

    Emphasizing definitions also makes it stand out where things BEGIN (not just methods). Indentation/whitespace in combo with the highlighting should tell you where methods begin.

    I think it’s “old habits die hard”, it actually took me a while to get used to this initially. But of course, tastes differ, maybe this is not for you.

  • balder

    yeah it’s certainly a personal taste. Making the boilerplate language keywords italic makes them stand out as much as making them bold for me. I prefer just not bold and another color. Just my 2cents.

  • That’s quite clever. I tend to use the marker feature in Eclipse. But your solution would often be a good addition.

  • dj

    italics suck…

  • Jack Law

    Isn’t public/private or static keyword part of the definition and actually important enough that it should be bold?

  • Erkki Lindpere

    Yeah, I was doubting whether to use italics or not, but without them it all looked very samey to me. Would be cool to experiment a little more with the scheme, though.

  • Erkki Lindpere

    I don’t think those are so important parts of the definition that you should be constantly aware of them rather than things like the method name, the parameter names etc. Another thought would be to emphasize types, but I’m not sure how well that would work in the 3 IDEs.

  • ikk

    Making the declaration of new identifiers stand out is a great idea. That should be the default in any syntax highlighter (the specific highlighting method – bold, color, etc. – does not matter much, though).

    While we are at it, could I suggest you to make the font of your blog darker and thicker? It looks like it was made to be unreadable on purpose. Maybe it looks great on the monitor the webdesigner used, but it’s very hard to read on my monitor (or maybe I need new glasses?). In fact, when I decide I’m going to read a full article, I open the dev tools in my browser and disable the CSS rules that make the text hard to read (font-weight and color)… Yeah, it’s that bad.

  • M Swathi

    Excellent information.
    Salesforce Training in Hyderabad

  • I think the IDE makers should go much further than the current configurability. To give some examples:

    * Font size: Method names (declaration) with bigger font size than the surrounding code.
    * Using a different font altogether for comments.
    * Wysiwyg-javadoc editing directly in the code editor.
    * Add your own syntax sugar, e.g. move the type specification to after the identifier: public doStuff(x: int): int
    * The keyword “public” is replaced by an icon.
    * And so on… endless possibilities

  • hii you are providing good information.Thanks for sharing if any one interested SAP APO

    Online training see below

    SAP APO Online