From 21e2d8f8b43302538702fe3ccaed32995c146c96 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 26 Oct 2017 13:30:31 -0700 Subject: make auto-appending closing chars more consistent --- vimrc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'vimrc') diff --git a/vimrc b/vimrc index 34306a0..387e6a2 100644 --- a/vimrc +++ b/vimrc @@ -566,16 +566,13 @@ nmap g) g0 nmap \ " }}} " auto-append closing characters {{{ -inoremap { {} -inoremap { {}O -inoremap {} {} -inoremap } strpart(getline('.'), col('.')-1, 1) == "}" ? "\" : "}" -inoremap ( () -inoremap ) strpart(getline('.'), col('.')-1, 1) == ")" ? "\" : ")" -inoremap [ [] -inoremap ] strpart(getline('.'), col('.')-1, 1) == "]" ? "\" : "]" -inoremap ' strpart(getline('.'), col('.')-1, 1) == "\'" ? "\" : col('.') == 1 \|\| match(strpart(getline('.'), col('.')-2, 1), '\W') != -1 ? "\'\'\" : "\'" -inoremap " strpart(getline('.'), col('.')-1, 1) == "\"" ? "\" : "\"\"\" +for pair in [['(', ')'], ['{', '}'], ['[', ']']] + exe "inoremap " . pair[0] . " " . pair[0] . pair[1] . "" + exe "inoremap " . pair[0] . " " . pair[0] . "" . pair[1] . "O" + exe "inoremap " . pair[1] . " strpart(getline('.'), col('.')-1, 1) == '" . pair[1] . "' ? '' : '" . pair[1] . "'" +endfor +inoremap ' strpart(getline('.'), col('.')-1, 1) == "\'" ? "\" : col('.') == 1 \|\| match(strpart(getline('.'), col('.')-2, 1), '\W') != -1 ? "\'\'\" : "\'" +inoremap " strpart(getline('.'), col('.')-1, 1) == "\"" ? "\" : "\"\"\" " }}} " tab for completion {{{ inoremap strpart(getline('.'), 0, col('.')-1) =~ '^\s*$' ? "\" : "\" -- cgit v1.2.3-54-g00ecf