From 0c58d72663c5a87c1f84a34dcfd805940c707fe9 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 31 May 2016 12:12:46 -0400 Subject: autoappend closing characters in vim --- vimrc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'vimrc') diff --git a/vimrc b/vimrc index 405974e..579ccb9 100644 --- a/vimrc +++ b/vimrc @@ -645,6 +645,18 @@ nmap ) 0 nmap g) g0 nmap \ " }}} +" auto-append closing characters {{{ +inoremap { {} +inoremap { {}O +inoremap {} {} +inoremap } strpart(getline('.'), col('.')-1, 1) == "}" ? "\" : col('.') == col('$') && match(getline(line('.') + 1), '^\s*}') != -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) == "\"" ? "\" : "\"\"\" +" }}} " Miscellaneous {{{ " have Y behave analogously to D rather than to dd nnoremap Y y$ -- cgit v1.2.3-54-g00ecf