0

我找到了关于自动完成括号的配置,

inoremap ' ''<Left>
inoremap " ""<Left>
inoremap { {}<Left>
inoremap ( ()<Left>

但是当我试图删除“(”时,“)”仍然存在,但在 Sublime Text 2 中,它也会消失。那么我该如何配置 .vimrc ro 呢?

// 更新:得到了 vim-autoclose 插件,现在似乎可以工作了。

4

1 回答 1

1

如果您安装了环绕.vim,您可以使用

inoremap ' ''<Left>
inoremap " ""<Left>
inoremap { {}<Left>
inoremap ( ()<Left>

imap <expr> <C-h> "\<C-\>\<C-n>x".((col('.')==col('$'))?(""):("h"))."a"
imap <BS>  <C-h>
let s:pairsymbols={"'": "'",
            \      '"': '"',
            \      '{': '}',
            \      '(': ')',}
function! s:DelPair()
    let cnt=v:count1
    if col('$')==1
        let shiftline=(line('.')<line('$'))
        normal! dd
        if shiftline
            normal! k
        endif
        normal! $
        if cnt>1
            execute 'normal '.(cnt-1).'x'
        endif
        return
    endif
    let curch=getline('.')[col('.')-1]
    if has_key(s:pairsymbols, curch)
        let oldchtick=b:changedtick
        if getline('.')[col('.')] is# s:pairsymbols[curch]
            normal! 2x
        else
            execute "normal \<Plug>Dsurround".s:pairsymbols[curch]
            if b:changedtick==oldchtick
                normal! x
            endif
        endif
    else
        normal! x
    endif
    if cnt>1
        execute 'normal '.(cnt-1).'x'
    endif
endfunction
nnoremap x :<C-u>call <SID>DelPair()<CR>
于 2011-12-25T17:06:06.787 回答