Adding color to bracket pairs

Mads Kristensen

When dealing with deeply nested brackets in Visual Studio, it can be hard to figure out which brackets match and which do not. For people with color blindness or other optic maladies, the problem can be even worse. By color-coding bracket pairs, we’re making this much easier.

Image screenshot

Various IDE’s and editors offer this feature today – usually done through extensions. For example, the Viasfora extension for Visual Studio has provided this feature for many years. What’s interesting about all these implementations is how they all do things a bit differently. Granted, they all colorize bracket pairs, but the way they do it differs and a lot of them provide additional features and options.

A feature request on the Visual Studio Developer Community is also now gaining steam asking for colorized bracket pairs, so please vote and comment if you agree.

So, with increased interest and multiple viable solutions, what would the right implementation look like for Visual Studio users?

Let’s do an experiment to find out.

The experiment

We’re starting out with an extension to kick off the experiment. We call it Rainbow Braces and the first iteration adds basic colorization to curly brackets, square brackets, and parentheses (see image above).

Image theme colors Figure 1: Colorized bracket pairs in both light and dark theme

It has four unique colors that it will cycle through and repeat for as many levels deep as needed. The colors work equally well for both light and dark themes and can be customized in the Fonts and Colors options page.

Image options

You can easily toggle the colorization on and off from the Edit -> Advanced top-level menu. Or use the keyboard shortcut Ctrl+Shift+9 to execute the Toggle Rainbow Braces command.

Image menu

Next steps

If this feature is interesting to you, please install the Rainbow Braces extensions and take it for a ride. Make sure to share any ideas and bugs on the GitHub issue tracker, and feel free to send pull requests too. The feature request ticket is a suitable place to share your comments and thoughts, so make sure to vote and comment there as well.

Do you like the idea of community experiments like this one? Let us know in the comments below.