This post is part of a series on new features in RStudio 1.4, currently available as a preview release.
Beautiful code themes and rainbow parentheses, a tale as old as…well at least 2017. Being able to color your parentheses (and brackets and braces) based on the level of nesting has been a highly requested feature for years and we’re happy to announce that it’s available in the upcoming 1.4 release of RStudio.
Enabling Rainbow Parentheses
Rainbow parentheses are turned off by default. To enable them:
Open Global Options from the Tools menu
Select Code -> Display
Enable the Rainbow Parentheses option at the bottom
If you would prefer to only use the Rainbow Parentheses option on a per-file basis (just for specific debugging, for example) you can toggle this option by using the Command Palette.
Open the Command Palette by either using the keyboard shortcut (Default: Control/Command + Shift + P) or through the Tools -> Command Palette menu option.
rainbowto quickly highlight the
Toggle Rainbow Parentheses Modeoption and select it to toggle the option.
This is on the file itself so the rest of your environment will continue to respect the global setting.
If you don’t like the default colors, or they don’t quite work for your theme, you can customize them to whatever you like. See this article on writing your own RStudio theme. The relevant classes to change are