Visual Studio plays catchup with VS Code again – this time with ‘Rainbow braces’

C# principal product manager Mads Kristensen has developed an extension for Visual Studio called Rainbow Braces that displays opening and closing curly brackets, parentheses and square brackets in matching colours in order to make it easier to identify the scope of a particular pair.

“Rainbow Braces makes it easier to make sense of nested code,” said Kristensen on Twitter, noting that the extension is a response to this feature request.

Bracket Pair Colorization, the same feature, was built into Visual Studio Code in version 1.60 a year ago. “I regularly use both VS Code and VS 2019/2022 and I would love to have this feature available in Visual Studio,” said the request.

The extension, however, has appeared under Kristensen’s name, not as an official Microsoft add-on. In the case of VS Code, converting the feature from an extension to a core part of the editor produced a claimed 10,000 times performance improvement.

The feature may seem small, but can save a lot of time peering through code trying to work out exactly where an extra or missing curly brace is breaking compilation. It can also help prevent errors, such as having a statement outside a for loop when it should be within it, or vice versa. It is the kind of feature which, once experienced, developers do not want to be without, particularly for curly brace languages such as C, C#, JavaScript and TypeScript.

Setting color options for Rainbow Braces in Visual Studio

There is already an extension called Viasfora that has this feature, among many others. Viasfora was inspired by a longstanding Vim plugin called Rainbow Parentheses, according to Viasfora creator Tomas Restrepo. Why then do Rainbow Braces? “Numerous people over the years have expressed a desire for a smaller extension that does nothing but rainbow bracing,” said Kristensen.

Microsoft is in the fortunate position of owning the two most popular IDEs, Visual Studio and VS Code. Officially Visual Studio, which runs on Windows and also has a Mac version, is a “comprehensive IDE”, while VS Code is “a standalone source code editor” that runs on Windows, Mac and Linux. In practice though, VS Code with the right extensions supports coding, compiling, unit testing, debugging, integration with source code repositories, and many advanced features that make it more like an IDE than just an editor.

Although Visual Studio retains some unique advantages for Windows development, it is now not uncommon for the “comprehensive IDE” to play catch-up with features that are already in VS Code. Another advantage of the open source editor is that it is pretty much the same on all platforms, whereas Visual Studio is very different on a Mac and does not run at all on Linux.

A couple of months ago, Microsoft previewed “the first version of Visual Studio that will natively support building and debugging Arm64 apps on Arm-based processors,” for example, something VS Code has been able to do for years. Visual Studio is a native code application whereas VS Code is JavaScript/TypeScript, making it more naturally cross-platform, though of the two it is still VS Code that starts up faster thanks to its smaller size.