sponsor Vim development Vim logo Vim Book Ad

WG Rainbow Delimiter Highlighter : highlights nested delimiters with different colors to aid readability

 script karma  Rating 12/5, Downloaded by 225  Comments, bugs, improvements  Vim wiki

created by
 
script type
syntax
 
description
Purpose and History:

This is a script for highlighting successive levels of nested delimiters (parentheses, square brackets, and squiggle brackets) with different colors, so that it is easier to see which matching pairs are associated with which levels of nesting in code.

It is especially useful for highly nested programming languages and/or those that don't have any/many precedence rules (such as Lisp/Scheme family languages of any kind, including even obscure and unknown ones and those not yet created), but it is also useful for any kind of text or programming language that uses nested parentheses, square brackets, and/or squiggly brackets. Those are the only delimiters it recolors.

The rainbow highlighting is overlaid on whatever other syntax highlighting you use and will leave other things untouched.

This script is based/built upon John Gilmore's original "Rainbow Parenthesis" [sic] (aka "RainbowParenthsis" [sic]) script, which can be found on the corresponding official Vim website page.

This rainbow highlighter doesn't muck around with anything on your system. It is strictly a simple one-file plain Vimscript-based plugin, using only Vim's provided built-in features without overengineering anything.

The core guiding principle of this script is to make it as easy to use as possible without overengineering it and without requiring any third party dependencies.

Script Usage:

Please read the accompanying README.md document and/or the comments contained in the Vimscript for more information.

This description is just a heavily trimmed version of it.

The script comes with many convenient function commands for precise control and is designed to be easy to customize.
 
install details
To use this script, all you have to do is place the Vimscript file into your %userprofile%/vimfiles/plugin (on Windows) or ~/.vim/plugin (on Linux/BSD/Unix) folder and it will load itself automatically whenever you use Vim.

Alternatively, running Windows_install.bat or Linux_etc_install.sh will try to do this automatically for you (like an installer).
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
WG_rainbow_highlighter_for_vim.zip v5 2024-10-07 8.2 The rainbow syntax highlighter now also supports "parallel editing" much better, by which I mean that if you have Vim (with `rainbow.vim` installed and active) and some other text editor open simultaneously (both of them editing the same file) then every time that you change window focus back to Vim then when it auto-reloads the file (at your request) then the rainbow delimiter syntax highlighting will no longer be lost but will now be automatically resynchronized and reapplied, thereby making working in parallel with both Vim and some other editor with this plugin much more pleasant and efficient.

Give it a try! It is a nice workflow.

(This patch is especially useful when working with DrRacket and Vim open side-by-side, but applies to all other programming languages (of course, as usual) and all 3rd party editors that support detection and/or reloading of externally modified files and hence support editing in parallel with Vim.)
WG_rainbow_highlighter_for_vim.zip v4 2024-10-01 8.2 This version fixes an important bug related to duplicates of `autocmd` being created unintentionally, which would cumulatively waste more and more time if/when the `rainbow.vim` script was repeatedly reloaded. The new version now uses `augroup` guards to protect against that problem. This should both improve performance and fix a problem where Vim would flicker many times (more than just the normal once) whenever the user switched between previous and next buffers and some other contexts.

The bug fix here is quite important, so I recommend that all users of this script download the new version!

Enjoy! I hope it helps make reading s-expression based code (and any other nested code) more legible and fun for you!
WG_rainbow_highlighter_for_vim.zip v3 2024-09-27 8.2 This release adds two new color themes, improves the contrast/legibility of prior dark and light themes even more, expands the number of levels supported slightly (for technical reasons to support improved color contrast), and makes various other refinements.

I've also fixed some important bugs. For example, the Linux installer was actually previously broken because I added quotes to a file path "for safety" but didn't test it and that ironically broke it... a classic programming blunder, heh... That's fixed now though.

Anyway though, this is another significant improvement. I hope you find it useful for reading highly nested code!
WG_rainbow_highlighter_for_vim.zip 2 2024-09-25 8.2 A new high contrast color theme was added (accessible via :RbHi), was set to the new default theme, an important GVim bug was fixed, and various minor documentation improvements were made.
WG_rainbow_highlighter_for_vim.zip 1 2024-09-24 8.2 Initial upload
ip used for rating: 18.97.9.175

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github