Merge branch 'master' of https://github.com/camthompson/auto-pairs into map_space
This commit is contained in:
commit
75b6bfb804
12
README.md
12
README.md
@ -25,6 +25,11 @@ Features
|
|||||||
|
|
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
* Insert spaces before closing characters
|
||||||
|
|
||||||
|
input: {|} (press <SPACE> at |)
|
||||||
|
output: { | }
|
||||||
|
|
||||||
* Skip closed bracket.
|
* Skip closed bracket.
|
||||||
|
|
||||||
input: []
|
input: []
|
||||||
@ -105,6 +110,13 @@ Options
|
|||||||
|
|
||||||
When g:AutoPairsMapCR is on, center current line after return if the line is at the bottom 1/3 of the window.
|
When g:AutoPairsMapCR is on, center current line after return if the line is at the bottom 1/3 of the window.
|
||||||
|
|
||||||
|
* g:AutoPairsMapSpace
|
||||||
|
|
||||||
|
Default : 1
|
||||||
|
|
||||||
|
Map <space> to insert a space after the opening character and before the closing one.
|
||||||
|
execute 'inoremap <buffer> <silent> <CR> <C-R>=AutoPairsReturn()<CR>'
|
||||||
|
|
||||||
TroubleShooting
|
TroubleShooting
|
||||||
---------------
|
---------------
|
||||||
The script will remap keys ([{'"}]) <BS>,
|
The script will remap keys ([{'"}]) <BS>,
|
||||||
|
@ -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
|
||||||
@ -177,6 +181,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
|
||||||
@ -196,6 +211,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…
Reference in New Issue
Block a user