mirror of
https://github.com/jiangmiao/auto-pairs.git
synced 2025-04-21 20:18:48 +08:00
Paramterise AutoPairsFastWrap() to allow for custom movements
By defining a movement parameter for AutoPairsFastWrap, we allow the user to define addition fast-wrap style mappings, for example: inoremap <buffer> <silent> <M-E> <C-R>=AutoPairsFastWrap("E")<CR> inoremap <buffer> <silent> <M-$> <C-R>=AutoPairsFastWrap("$")<CR> Whilst it might, in the future, seem appropriate/sensible/whatever to add these as default mapping to auto-pairs, this change allows experimentation in the short term.
This commit is contained in:
parent
39f06b873a
commit
648034ccb8
@ -334,7 +334,7 @@ endf
|
||||
|
||||
|
||||
" Fast wrap the word in brackets
|
||||
func! AutoPairsFastWrap()
|
||||
func! AutoPairsFastWrap(movement)
|
||||
let c = @"
|
||||
normal! x
|
||||
let [before, after, ig] = s:getline()
|
||||
@ -354,7 +354,7 @@ func! AutoPairsFastWrap()
|
||||
end
|
||||
endfor
|
||||
if after[1:1] =~ '\v\w'
|
||||
normal! e
|
||||
execute "normal! ".a:movement
|
||||
normal! p
|
||||
else
|
||||
normal! p
|
||||
@ -559,7 +559,7 @@ func! AutoPairsInit()
|
||||
end
|
||||
|
||||
if g:AutoPairsShortcutFastWrap != ''
|
||||
execute 'inoremap <buffer> <silent> '.g:AutoPairsShortcutFastWrap.' <C-R>=AutoPairsFastWrap()<CR>'
|
||||
execute 'inoremap <buffer> <silent> '.g:AutoPairsShortcutFastWrap.' <C-R>=AutoPairsFastWrap("e")<CR>'
|
||||
end
|
||||
|
||||
if g:AutoPairsShortcutBackInsert != ''
|
||||
|
Loading…
x
Reference in New Issue
Block a user