Vim基础篇(十)——括号配对高亮插件rainbow

前言:
  代码编辑时常出现括号层层嵌套,让人眼花缭乱,通过颜色高亮能够帮助我们一眼看出配对的括号,同时也使得Vim显示更美化。

1 安装auto-pairs

   luochen1990/rainbow 可以成对的高亮显示括号,对阅读代码十分有益。
  通过vim-plug安装 rainbow 需要在.vimrc配置文件中添加以下配置。

1
Plug 'luochen1990/rainbow'

  之后在Vim中执行指令 :PlugInstall 安装插件。

2 配置auto-pairs

  可以使用默认配置,也可使用作者推荐的配置,我个人使用偏暗色的默认配置。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 let g:rainbow_active = 1

let g:rainbow_conf = {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
\ 'guis': [''],
\ 'cterms': [''],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'markdown': {
\ 'parentheses_options': 'containedin=markdownCode contained',
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\ },
\ 'haskell': {
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\v\{\ze[^-]/ end=/}/ fold'],
\ },
\ 'vim': {
\ 'parentheses_options': 'containedin=vimFuncBody',
\ },
\ 'perl': {
\ 'syn_name_prefix': 'perlBlockFoldRainbow',
\ },
\ 'stylus': {
\ 'parentheses': ['start=/{/ end=/}/ fold contains=@colorableGroup'],
\ },
\ 'css': 0,
\ }
\}

rainbow.png