Tip Tuesday: the Indent Rainbow plugin

No more grief when working with pesky openapi.yaml files

illustrations illustrations illustrations illustrations

Published on 21st June 2022 by Madeleine Smith

A feature image consisting of ‘Indent Rainbow’ as text on a background of multiple bands of bright colors

I recently discovered the IDE plugin Indent Rainbow whilst trying to solve a frustration I’d been experiencing when working with openapi files.

With one of my clients I’m working with a large openapi.yaml file. This file defines our API and describes each of our endpoints in minute detail - request parameters, bodies, expected responses etc. Though I always found pasting code into this file was a mildly frustrating experience.

Having the correct indentation is crucial in YAML files, meaning that to paste the code in the right place, I was having to either count the number of indentation guide lines from the left or follow a specific line down with my cursor. Neither of these are great! Also, my IDE (Goland) always seems to mess up the indentation whenever I paste, but that’s a different story!

So I wanted to find a plugin which would make this a bit easier. And Indent Rainbow seemed to fit the bill. Indent Rainbow is a plugin for IDEs (e.g. JetBrains products and VS Code) which colors each of your indentation ‘steps’. And this, in turn, makes the indentation easier to read.

So, for example, this is how one of the files I’m working on as part of a side project looks like in my IDE:

A screenshot of code in my IDE with each indentation step colored in a pastel color
The above file is used to control the color and brightness of a smart bulb - see the pretty indentation colors on the left 🥰

However, Indent Rainbow is, by default, disabled on files with over 1000 lines. This setting can be overruled, though I had previously found it to be incredibly slow when working on an openapi file of almost 6000 lines. And this meant that, frustratingly, I’d have to leave the plugin disabled for large files and thus my original problem would remain.

(╯°□°)╯︵ ┻━┻

However, as of the time of writing, it would seem this has been fixed as working with large files is no longer deathly slow. Whoop! Now I think I’m going to leave this plugin enabled all the time - even for large files 💯


In need of a back-end engineer for your project? Get in touch to hire me for contract work 💯