summaryrefslogtreecommitdiffstats
path: root/vimrc
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2016-05-31 12:12:46 -0400
committerJesse Luehrs <doy@tozt.net>2016-05-31 12:13:57 -0400
commit0c58d72663c5a87c1f84a34dcfd805940c707fe9 (patch)
tree7fd13a335542708c5405684a83dba36a9c4edfe0 /vimrc
parent6d7cbff74daa0a7706b43cfebaf4eab0319b1956 (diff)
downloadconf-0c58d72663c5a87c1f84a34dcfd805940c707fe9.tar.gz
conf-0c58d72663c5a87c1f84a34dcfd805940c707fe9.zip
autoappend closing characters in vim
Diffstat (limited to 'vimrc')
-rw-r--r--vimrc12
1 files changed, 12 insertions, 0 deletions
diff --git a/vimrc b/vimrc
index 405974e..579ccb9 100644
--- a/vimrc
+++ b/vimrc
@@ -645,6 +645,18 @@ nmap <silent>) 0
nmap <silent>g) g0
nmap <Bar> \
" }}}
+" auto-append closing characters {{{
+inoremap { {}<Left>
+inoremap {<CR> {<CR>}<Esc>O
+inoremap {} {}
+inoremap <expr> } strpart(getline('.'), col('.')-1, 1) == "}" ? "\<Right>" : col('.') == col('$') && match(getline(line('.') + 1), '^\s*}') != -1 ? "\<Down>\<C-o>$" : "}"
+inoremap ( ()<Left>
+inoremap <expr> ) strpart(getline('.'), col('.')-1, 1) == ")" ? "\<Right>" : ")"
+inoremap [ []<Left>
+inoremap <expr> ] strpart(getline('.'), col('.')-1, 1) == "]" ? "\<Right>" : "]"
+inoremap <expr> ' strpart(getline('.'), col('.')-1, 1) == "\'" ? "\<Right>" : col('.') == 1 \|\| match(strpart(getline('.'), col('.')-2, 1), '\W') != -1 ? "\'\'\<Left>" : "\'"
+inoremap <expr> " strpart(getline('.'), col('.')-1, 1) == "\"" ? "\<Right>" : "\"\"\<Left>"
+" }}}
" Miscellaneous {{{
" have Y behave analogously to D rather than to dd
nnoremap Y y$