summaryrefslogtreecommitdiffstats
path: root/vimrcs/match.vim
blob: 897b3c7388bb79ecd8f710a6f5e091a6253fe15a (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