The code on this page may only works on GNU/Linux system only.
			
function! GetChar(...)
	return matchstr(getline('.'), '\%' . (col('.')-a:1) . 'c.')
endfunction
inoremap <expr> ' (GetChar(0) ==# "'" ? "<Right>" : "''<Left>")
inoremap <expr> " (GetChar(0) ==# '"' ? '<Right>' : '""<Left>')
inoremap ( ()<Left>
inoremap <expr> ) (GetChar(0) ==# ")" ? "<Right>" : ")")
inoremap [ []<Left>
inoremap <expr> ] (GetChar(0) ==# "]" ? "<Right>" : "]")
inoremap <expr> { ((GetChar(1) ==# " " && GetChar(2) ==# ")") \|\| GetChar(1) ==# ")" ? "{<CR><CR>}<Up><Tab>" : "{}<Left>")
inoremap <expr> } (GetChar(0) ==# "}" ? "<Right>" : "}")
			
		
		Let me talk about the meaning of the code above!
				
function! GetChar(...)
	return matchstr(getline('.'), '\%' . (col('.')-a:1) . 'c.')
endfunction
				
			
			
				
inoremap <expr> ' (GetChar(0) ==# "'" ? "<Right>" : "''<Left>")
				
			
			
				
inoremap <expr> " (GetChar(0) ==# '"' ? '<Right>' : '""<Left>')
				
			
			
				
inoremap ( ()<Left>
				
			
			
				
inoremap <expr> ) (GetChar(0) ==# ")" ? "<Right>" : ")")
				
			
			
				
inoremap [ []<Left>
				
			
			
				
inoremap <expr> ] (GetChar(0) ==# "]" ? "<Right>" : "]")
				
			
			
				
inoremap <expr> { ((GetChar(1) ==# " " && GetChar(2) ==# ")") \|\| GetChar(1) ==# ")" ? "{<CR><CR>}<Up><Tab>" : "{}<Left>")
				
			
			
				
inoremap <expr> } (GetChar(0) ==# "}" ? "<Right>" : "}")
				
			
		Lastest update: Sep 7th 2025