fast wrap
This commit is contained in:
parent
e893ae3d48
commit
bb0b47e4a1
15
README.md
15
README.md
@ -26,7 +26,7 @@ Features
|
|||||||
}
|
}
|
||||||
|
|
||||||
### Skip closed bracket.
|
### Skip closed bracket.
|
||||||
|
call feedkeys(
|
||||||
input: []
|
input: []
|
||||||
output: []
|
output: []
|
||||||
|
|
||||||
@ -35,6 +35,10 @@ Features
|
|||||||
input: "\'
|
input: "\'
|
||||||
output: "\'"
|
output: "\'"
|
||||||
|
|
||||||
|
### Fast Wrap
|
||||||
|
input: |'hello' (press (<M-e> at|)
|
||||||
|
output: ('hello')
|
||||||
|
|
||||||
|
|
||||||
Shortcuts
|
Shortcuts
|
||||||
---------
|
---------
|
||||||
@ -43,6 +47,7 @@ Shortcuts
|
|||||||
<CR> : Insert new indented line after return if cursor in blank brackets or quotes.
|
<CR> : Insert new indented line after return if cursor in blank brackets or quotes.
|
||||||
<BS> : Delete brackets in pair
|
<BS> : Delete brackets in pair
|
||||||
<M-p> : Toggle Autopairs
|
<M-p> : Toggle Autopairs
|
||||||
|
<M-e> : Fast Wrap
|
||||||
|
|
||||||
Optional Shortcuts:
|
Optional Shortcuts:
|
||||||
could be turn off by let g:AutoPairsShortcuts = 0
|
could be turn off by let g:AutoPairsShortcuts = 0
|
||||||
@ -62,6 +67,14 @@ Options
|
|||||||
|
|
||||||
The shortcut to toggle autopairs.
|
The shortcut to toggle autopairs.
|
||||||
|
|
||||||
|
* g:AutoPairsShortcutFastWrap
|
||||||
|
|
||||||
|
Default: '<M-e>'
|
||||||
|
|
||||||
|
Fast wrap the word. all pairs will be consider as a block (include <>).
|
||||||
|
(|)'hello' after fast wrap at |, the word will be ('hello')
|
||||||
|
(|)<hello> after fast wrap at |, the word will be (<hello>)
|
||||||
|
|
||||||
* g:AutoPairsShortcuts
|
* g:AutoPairsShortcuts
|
||||||
|
|
||||||
Default: 1
|
Default: 1
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
" Insert or delete brackets, parens, quotes in pairs.
|
" Insert or delete brackets, parens, quotes in pairs.
|
||||||
" Maintainer: JiangMiao <jiangfriend@gmail.com>
|
" Maintainer: JiangMiao <jiangfriend@gmail.com>
|
||||||
" Last Change: 2011-06-07
|
" Last Change: 2011-06-10
|
||||||
" Version: 1.0.2
|
" Version: 1.0.3
|
||||||
" Homepage: http://www.vim.org/scripts/script.php?script_id=3599
|
" Homepage: http://www.vim.org/scripts/script.php?script_id=3599
|
||||||
" Repository: https://github.com/jiangmiao/auto-pairs
|
" Repository: https://github.com/jiangmiao/auto-pairs
|
||||||
|
|
||||||
@ -21,6 +21,8 @@ end
|
|||||||
if !exists('g:AutoPairs')
|
if !exists('g:AutoPairs')
|
||||||
let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"'}
|
let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"'}
|
||||||
end
|
end
|
||||||
|
let g:AutoExtraPairs = copy(g:AutoPairs)
|
||||||
|
let g:AutoExtraPairs['<'] = '>'
|
||||||
|
|
||||||
if !exists('g:AutoPairsMapBS')
|
if !exists('g:AutoPairsMapBS')
|
||||||
let g:AutoPairsMapBS = 1
|
let g:AutoPairsMapBS = 1
|
||||||
@ -113,20 +115,20 @@ function! AutoPairsExtend()
|
|||||||
let current_char = line[col('.')-1]
|
let current_char = line[col('.')-1]
|
||||||
let next_char = line[col('.')]
|
let next_char = line[col('.')]
|
||||||
|
|
||||||
|
normal! x
|
||||||
if has_key(g:AutoPairsClosedPairs, current_char)
|
if match(next_char, '\s') != -1
|
||||||
if has_key(g:AutoPairs, next_char)
|
call search('\S', 'W')
|
||||||
let open = next_char
|
let next_char = getline('.')[col('.')-1]
|
||||||
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."\<LEFT>"
|
|
||||||
return ''
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return ''
|
if has_key(g:AutoExtraPairs, next_char)
|
||||||
|
let close = g:AutoExtraPairs[next_char]
|
||||||
|
call search(close, 'W')
|
||||||
|
return "\<RIGHT>".current_char."\<LEFT>"
|
||||||
|
else
|
||||||
|
execute "normal! ea".current_char
|
||||||
|
return ""
|
||||||
|
end
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! AutoPairsMap(key)
|
function! AutoPairsMap(key)
|
||||||
|
Loading…
Reference in New Issue
Block a user