This commit is contained in:
2026-07-12 08:16:17 +03:30
commit 72be1234e1
2027 changed files with 221388 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
function! Sc(char)
let closing = {'(': ')', '[': ']', '{': '}', '<': '>', '"': '"', "'": "'"}
if has_key(closing, a:char)
let line = getline('.')
let col = col('.') - 1
let before = col > 0 ? line[col-1] : ''
let after = col < len(line) ? line[col] : ''
if before =~ '\w' && after =~ '\w'
return a:char
endif
if (a:char == '"' || a:char == "'") && before == a:char
return a:char
endif
if after == closing[a:char]
return "\<Right>"
endif
return a:char . closing[a:char] . "\<Left>"
endif
return a:char
endfunction
inoremap ( <C-R>=Sc('(')<CR>
inoremap [ <C-R>=Sc('[')<CR>
inoremap { <C-R>=Sc('{')<CR>
inoremap < <C-R>=Sc('<')<CR>
inoremap " <C-R>=Sc('"')<CR>
inoremap ' <C-R>=Sc("'")<CR>