WG Rainbow Delimiter Highlighter : highlights nested delimiters with different colors to aid readability
| script karma |
Rating 12/5,
Downloaded by 729 |
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). |
| |
script versions (upload new version)
Click on the package to download.
| WG_rainbow_highlighter_for_Vim_v6_2025-10-05.zip |
v6 |
2025-10-05 |
8.2 |
|
In V6, the Linux bug where some Windows newlines caused the plugin to break has been fixed:
The previous release of my rainbow highlighter (v5) accidentally included Windows-based newlines that caused the plugin to fail to load on Linux systems that did not have automatic line ending conversion set up for Vim or elsewhere. The most significant part of this new release here (v6) is that it fixes that problem, thus preventing new users on Linux from having to manually fix the line ending problem (e.g. via :w ++ff=unix in Vim) or to be misled into thinking that the script was otherwise broken.
Windows was previously my main operating system but now I use Linux, so testing of this plugin's Linux support has become more regular and more comprehensive. Sorry about not being more careful about that before! I had tested the plugin before on one Linux system and didn't realize the file's bad newlines were present and could cause errors under other circumstances (e.g. systems that aren't set up to fix that automatically). I also made a variety of other small improvements to the documentation and code.
Advantages of this plugin over some other rainbow highlighters
As before, this rainbow syntax highlighter supports great ease of use, including:
- Supporting parallel editing in both Vim and any editor that supports detection of changes and reloading (e.g. DrRacket via pressing Ctrl Shift E, Geany, etc), thus enabling you to have the best of both worlds: (1) rainbow highlighting and fast edits via Vim and (2) whatever features your other editor provides. It is a very useful workflow!
- Working even on unknown file extensions (such as for a programming language you yourself are designing) and without the need to depend on any 3rd party plugin systems since mine uses only native Vim features.
- Having a large set of useful shorthand commands for controlling color themes and switching between them.
- Aesthetically pleasing and well contrasted color sets that create a good experience right out of the box.
- A lack of overengineering compared to some other rainbow highlighters. This plugin keeps it simple and direct!
- Info about the wide range of different Lisp/Scheme/s-expression based languages that exist and recommendations on some to try, which may be found in the main rainbow.vim script under the If you're having trouble deciding what language to use comment heading.
Give it a try! It is really easy to set up and useful!
It has been tested to work on Vim 8.2 and 9 and probably works on a bunch of other versions too. It is a simple script.
|
| 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: 216.73.216.103
|