Prevent jumping if open key equals close key, fixes #231
This commit is contained in:
parent
4af571e18b
commit
c2f0eef628
27
README.md
27
README.md
@ -308,27 +308,16 @@ Multibyte Pairs
|
|||||||
The text after // in close pair is modifiers
|
The text after // in close pair is modifiers
|
||||||
|
|
||||||
n - do not map the first charactor of closed pair to close key
|
n - do not map the first charactor of closed pair to close key
|
||||||
s - do not jump through multi line
|
m - close key jumps through multi line
|
||||||
|
s - close key jumps only in the same line
|
||||||
|
|
||||||
pair: "'''":"'''"
|
by default if open key equals close key the multi line is turn off
|
||||||
input:
|
|
||||||
'''
|
|
||||||
|
|
|
||||||
''' (press ')
|
|
||||||
output:
|
|
||||||
'''
|
|
||||||
|
|
||||||
'''|
|
"<?": "?>" ? jumps only in the same line
|
||||||
|
"<?": "?>//m" force ? jumping through multi line
|
||||||
pair: "'''":"'''//s"
|
"<?php":"?>" ? will jump through multi line
|
||||||
input:
|
"<?php":"?>//s" force ? only jumping in the same line
|
||||||
'''
|
"<?": "?>//n" do not jump totally
|
||||||
|
|
|
||||||
''' (press ')
|
|
||||||
output:
|
|
||||||
'''
|
|
||||||
'|'
|
|
||||||
'''
|
|
||||||
|
|
||||||
for 'begin' 'end' pair, e is a charactor, if map e to jump will be annoy, so use modifier 'n' to skip key map
|
for 'begin' 'end' pair, e is a charactor, if map e to jump will be annoy, so use modifier 'n' to skip key map
|
||||||
|
|
||||||
|
@ -393,6 +393,9 @@ func! AutoPairsSpace()
|
|||||||
let [before, after, ig] = s:getline()
|
let [before, after, ig] = s:getline()
|
||||||
|
|
||||||
for [open, close, opt] in b:AutoPairsList
|
for [open, close, opt] in b:AutoPairsList
|
||||||
|
if close == ''
|
||||||
|
continue
|
||||||
|
end
|
||||||
if before =~ '\V'.open.'\v$' && after =~ '^\V'.close
|
if before =~ '\V'.open.'\v$' && after =~ '^\V'.close
|
||||||
return "\<SPACE>\<SPACE>".s:Left
|
return "\<SPACE>\<SPACE>".s:Left
|
||||||
end
|
end
|
||||||
@ -444,20 +447,29 @@ func! AutoPairsInit()
|
|||||||
let b:AutoPairsList = []
|
let b:AutoPairsList = []
|
||||||
|
|
||||||
" buffer level map pairs keys
|
" buffer level map pairs keys
|
||||||
|
" n - do not map the first charactor of closed pair to close key
|
||||||
|
" m - close key jumps through multi line
|
||||||
|
" s - close key jumps only in the same line
|
||||||
for [open, close] in items(b:AutoPairs)
|
for [open, close] in items(b:AutoPairs)
|
||||||
let o = open[len(open)-1]
|
let o = open[-1:-1]
|
||||||
let m = matchlist(close, '\v(.*)//(.*)$')
|
let c = close[0]
|
||||||
let opt = {'mapclose': 1, 'multiline':1}
|
let opt = {'mapclose': 1, 'multiline':1}
|
||||||
|
if o == c
|
||||||
|
let opt['multiline'] = 0
|
||||||
|
end
|
||||||
|
let m = matchlist(close, '\v(.*)//(.*)$')
|
||||||
if len(m) > 0
|
if len(m) > 0
|
||||||
if m[2] =~ 'n'
|
if m[2] =~ 'n'
|
||||||
let opt['mapclose'] = 0
|
let opt['mapclose'] = 0
|
||||||
end
|
end
|
||||||
|
if m[2] =~ 'm'
|
||||||
|
let opt['multiline'] = 1
|
||||||
|
end
|
||||||
if m[2] =~ 's'
|
if m[2] =~ 's'
|
||||||
let opt['multiline'] = 0
|
let opt['multiline'] = 0
|
||||||
end
|
end
|
||||||
let close = m[1]
|
let close = m[1]
|
||||||
end
|
end
|
||||||
let c = close[0]
|
|
||||||
call AutoPairsMap(o)
|
call AutoPairsMap(o)
|
||||||
if o != c && c != '' && opt['mapclose']
|
if o != c && c != '' && opt['mapclose']
|
||||||
call AutoPairsMap(c)
|
call AutoPairsMap(c)
|
||||||
|
Loading…
Reference in New Issue
Block a user