README.md (4512B)
1 Rainbow Parentheses Improved 2 === 3 > help you read complex code by showing diff level of parentheses in diff color !! 4 5 Description [(这里有中文版)](https://github.com/luochen1990/rainbow/blob/master/README_zh.md) 6 --------------------------------------------------------------------------------------------------- 7 8 As everyone knows, the most complex codes were composed of a mass of different kinds of parentheses (typically: lisp). 9 This plugin will help you read these codes by showing different levels of parentheses in different colors. 10 You can also find this plugin in **[www.vim.org](http://www.vim.org/scripts/script.php?script_id=4176)**. 11 12 #### lisp 13 ![lisp](https://raw.githubusercontent.com/luochen1990/rainbow/demo/lisp.png) 14 #### html 15 ![html](https://raw.githubusercontent.com/luochen1990/rainbow/demo/html.png) 16 #### [more](https://github.com/luochen1990/rainbow/blob/demo/more.md) 17 18 ### What is improved ? 19 20 - no limit of parentheses levels. 21 - separately edit guifgs and ctermfgs (the colors used for highlighting). 22 - now you can design your own parentheses such as 'begin' and 'end'. 23 - you can also configure anything separately for different types of files. 24 - now you can even decide to let some operators (like + - * / , ==) highlighted with the parentheses together. 25 - json style configuration used, more understandable and readable, easier for advanced configuration. 26 - the code is shorter and easier to read now. 27 - smoother and faster. 28 - the Chinese document is added. 29 30 ### Referenced: 31 - http://www.vim.org/scripts/script.php?script_id=1561 (Martin Krischik) 32 - http://www.vim.org/scripts/script.php?script_id=3772 (kien) 33 34 Install: 35 -------- 36 37 ### via Vundle: 38 39 ```vim 40 Plugin 'luochen1990/rainbow' 41 let g:rainbow_active = 1 "0 if you want to enable it later via :RainbowToggle 42 ``` 43 44 ### Manually: 45 - first, put `rainbow.vim`(this file) to dir `~/.vim/plugin` or `vimfiles/plugin` 46 - second, add the follow sentences to your `.vimrc` or `_vimrc` : 47 48 ```vim 49 let g:rainbow_active = 1 "0 if you want to enable it later via :RainbowToggle 50 ``` 51 52 - third, restart your vim and enjoy coding. 53 54 Configure: 55 ---------- 56 57 There is an example for advanced configuration (which I'm using), add it to your vimrc and edit it as you wish (just keep the format). 58 59 ```vim 60 let g:rainbow_conf = { 61 \ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'], 62 \ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'], 63 \ 'operators': '_,_', 64 \ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'], 65 \ 'separately': { 66 \ '*': {}, 67 \ 'tex': { 68 \ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'], 69 \ }, 70 \ 'lisp': { 71 \ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'], 72 \ }, 73 \ 'vim': { 74 \ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'], 75 \ }, 76 \ 'html': { 77 \ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'], 78 \ }, 79 \ 'css': 0, 80 \ } 81 \} 82 ``` 83 84 - 'guifgs': colors for gui interface, will be used in order. 85 - 'ctermfgs': colors for terms. 86 - 'operators': describe the operators you want to highlight (note: be careful about special characters which needs escaping, you can find more examples [here](https://github.com/luochen1990/rainbow/issues/3), and you can also read the [vim help about syn-pattern](http://vimdoc.sourceforge.net/htmldoc/syntax.html#:syn-pattern)). 87 - 'parentheses': describe what will be processed as parentheses, a pair of parentheses was described by two re pattern. 88 - 'separately': configure for specific filetypes (decided by &ft), key `*` for filetypes without separate configuration, value `0` means disable rainbow only for this type of files. 89 - keep a field empty to use the default setting. 90 91 User Command: 92 ------------- 93 94 - **:RainbowToggle** --you can use it to toggle this plugin. 95 96 ------------------------------------------------------------------ 97 **Rate this script if you like it, and I'll appreciate it and improve this plugin for you because of your support! 98 99 Just go to [this page](http://www.vim.org/scripts/script.php?script_id=4176) and choose `Life Changing` and click `rate`**