aboutsummaryrefslogtreecommitdiffstats
path: root/vim/vimrcs/match.vim
blob: 0b2c19b276d7387e25df7e39b2e94bfaed751a87 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
" 各类符号自动匹配
inoremap { {<CR>}<ESC>O
" :inoremap { {}<ESC>i
" :inoremap } <c-r>=ClosePair('}')<CR>
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i

function ClosePair(char)
	if getline('.')[col('.') - 1] == a:char
		return "<Right>"
	else
		return a:char
	endif
endfunction