aboutsummaryrefslogtreecommitdiffstats
path: root/vim/vimrcs/match.vim
blob: 279a33f434890fffbb7eb6e972c78b209d1401a8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"各类符号自动匹配
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {}<ESC>i
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
 
function ClosePair(char)
    if getline('.')[col('.') - 1] == a:char
        return "<Right>"
    else
        return a:char
    endif
endfunction