fixes #23: Support typographer's quote pairs, such as ‘, ’, “, ”

This commit is contained in:
Miao Jiang 2012-10-09 15:00:34 +08:00
parent 1c5046f8c3
commit 9758a447cf

View File

@ -72,9 +72,12 @@ function! AutoPairsInsert(key)
end
let line = getline('.')
let prev_char = line[col('.')-2]
let current_char = line[col('.')-1]
let next_char = line[col('.')]
let pos = col('.') - 1
let next_chars = split(strpart(line, pos), '\zs')
let current_char = get(next_chars, 0, '')
let next_char = get(next_chars, 1, '')
let prev_chars = split(strpart(line, 0, pos), '\zs')
let prev_char = get(prev_chars, -1, '')
let eol = 0
if col('$') - col('.') <= 1
@ -151,9 +154,11 @@ endfunction
function! AutoPairsDelete()
let line = getline('.')
let current_char = line[col('.')-1]
let prev_char = line[col('.')-2]
let pprev_char = line[col('.')-3]
let pos = col('.') - 1
let current_char = get(split(strpart(line, pos), '\zs'), 0, '')
let prev_chars = split(strpart(line, 0, pos), '\zs')
let prev_char = get(prev_chars, -1, '')
let pprev_char = get(prev_chars, -2, '')
if pprev_char == '\'
return "\<BS>"