diff --git a/README.md b/README.md index 04943f2..7b0dab4 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Features } ### Skip closed bracket. - +call feedkeys( input: [] output: [] @@ -35,6 +35,10 @@ Features input: "\' output: "\'" +### Fast Wrap + input: |'hello' (press ( at|) + output: ('hello') + Shortcuts --------- @@ -43,6 +47,7 @@ Shortcuts : Insert new indented line after return if cursor in blank brackets or quotes. : Delete brackets in pair : Toggle Autopairs + : Fast Wrap Optional Shortcuts: could be turn off by let g:AutoPairsShortcuts = 0 @@ -62,6 +67,14 @@ Options The shortcut to toggle autopairs. +* g:AutoPairsShortcutFastWrap + + Default: '' + + Fast wrap the word. all pairs will be consider as a block (include <>). + (|)'hello' after fast wrap at |, the word will be ('hello') + (|) after fast wrap at |, the word will be () + * g:AutoPairsShortcuts Default: 1 diff --git a/plugin/auto-pairs.vim b/plugin/auto-pairs.vim index e51f27a..34c7148 100644 --- a/plugin/auto-pairs.vim +++ b/plugin/auto-pairs.vim @@ -1,7 +1,7 @@ " Insert or delete brackets, parens, quotes in pairs. " Maintainer: JiangMiao -" Last Change: 2011-06-07 -" Version: 1.0.2 +" Last Change: 2011-06-10 +" Version: 1.0.3 " Homepage: http://www.vim.org/scripts/script.php?script_id=3599 " Repository: https://github.com/jiangmiao/auto-pairs @@ -21,6 +21,8 @@ end if !exists('g:AutoPairs') let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"'} end +let g:AutoExtraPairs = copy(g:AutoPairs) +let g:AutoExtraPairs['<'] = '>' if !exists('g:AutoPairsMapBS') let g:AutoPairsMapBS = 1 @@ -112,21 +114,21 @@ function! AutoPairsExtend() let line = getline('.') let current_char = line[col('.')-1] let next_char = line[col('.')] - - - if has_key(g:AutoPairsClosedPairs, current_char) - if has_key(g:AutoPairs, next_char) - let open = next_char - let close = g:AutoPairs[next_char] - let quote_pattern = '(?:\\\|\"\|[^"])*' - echoe 'search pair '.open.' '.close - call searchpair(open, '', close, 'W') - end - execute "normal! a".current_char."\" - return '' + + normal! x + if match(next_char, '\s') != -1 + call search('\S', 'W') + let next_char = getline('.')[col('.')-1] end - return '' + if has_key(g:AutoExtraPairs, next_char) + let close = g:AutoExtraPairs[next_char] + call search(close, 'W') + return "\".current_char."\" + else + execute "normal! ea".current_char + return "" + end endfunction function! AutoPairsMap(key)