Add AutoPairsMapSpace option
When g:AutoPairsMapSpace == 1, a space key after a character in AutoPairs will expand to a space after the previous character and a space before the next character. With ^ being the cursor position, pressing space will turn [^] into [ ^ ].
This commit is contained in:
parent
e0d5dab300
commit
1522bff476
@ -32,6 +32,10 @@ if !exists('g:AutoPairsMapCR')
|
|||||||
let g:AutoPairsMapCR = 1
|
let g:AutoPairsMapCR = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if !exists('g:AutoPairsMapSpace')
|
||||||
|
let g:AutoPairsMapSpace = 1
|
||||||
|
end
|
||||||
|
|
||||||
if !exists('g:AutoPairsCenterLine')
|
if !exists('g:AutoPairsCenterLine')
|
||||||
let g:AutoPairsCenterLine = 1
|
let g:AutoPairsCenterLine = 1
|
||||||
end
|
end
|
||||||
@ -170,6 +174,17 @@ function! AutoPairsReturn()
|
|||||||
return "\<CR>"
|
return "\<CR>"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! AutoPairsSpace()
|
||||||
|
let line = getline('.')
|
||||||
|
let prev_char = line[col('.')-2]
|
||||||
|
let cmd = ''
|
||||||
|
let cur_char =line[col('.')-1]
|
||||||
|
if has_key(g:AutoPairs, prev_char) && g:AutoPairs[prev_char] == cur_char
|
||||||
|
let cmd = "\<SPACE>\<ESC>i"
|
||||||
|
endif
|
||||||
|
return "\<SPACE>".cmd
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! AutoPairsInit()
|
function! AutoPairsInit()
|
||||||
let b:autopairs_loaded = 1
|
let b:autopairs_loaded = 1
|
||||||
let b:autopairs_enabled = 1
|
let b:autopairs_enabled = 1
|
||||||
@ -189,6 +204,10 @@ function! AutoPairsInit()
|
|||||||
execute 'inoremap <buffer> <silent> <expr> <CR> AutoPairsReturn()'
|
execute 'inoremap <buffer> <silent> <expr> <CR> AutoPairsReturn()'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if g:AutoPairsMapSpace
|
||||||
|
execute 'inoremap <buffer> <silent> <expr> <space> AutoPairsSpace()'
|
||||||
|
end
|
||||||
|
|
||||||
execute 'inoremap <buffer> <silent> '.g:AutoPairsShortcutFastWrap.' <C-R>=AutoPairsFastWrap()<CR>'
|
execute 'inoremap <buffer> <silent> '.g:AutoPairsShortcutFastWrap.' <C-R>=AutoPairsFastWrap()<CR>'
|
||||||
execute 'inoremap <buffer> <silent> <expr> '.g:AutoPairsShortcutToggle.' AutoPairsToggle()'
|
execute 'inoremap <buffer> <silent> <expr> '.g:AutoPairsShortcutToggle.' AutoPairsToggle()'
|
||||||
execute 'noremap <buffer> <silent> '.g:AutoPairsShortcutToggle.' :call AutoPairsToggle()<CR>'
|
execute 'noremap <buffer> <silent> '.g:AutoPairsShortcutToggle.' :call AutoPairsToggle()<CR>'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user