Fix sometimes <ESC> failde.
This commit is contained in:
parent
d4acd6e014
commit
7a10f7604c
@ -1,7 +1,7 @@
|
|||||||
" Language: JavaScript
|
" Language: JavaScript
|
||||||
" Maintainer: JiangMiao <jiangfriend@gmail.com>
|
" Maintainer: JiangMiao <jiangfriend@gmail.com>
|
||||||
" Last Change: 2011-05-22
|
" Last Change: 2011-05-22
|
||||||
" Version: 1.0
|
" Version: 1.0.1
|
||||||
" Repository: https://github.com/jiangmiao/auto-pairs
|
" Repository: https://github.com/jiangmiao/auto-pairs
|
||||||
"
|
"
|
||||||
" Insert or delete brackets, parens, quotes in pairs.
|
" Insert or delete brackets, parens, quotes in pairs.
|
||||||
@ -23,6 +23,9 @@ if !exists('g:AutoPairs')
|
|||||||
let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"'}
|
let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"'}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let g:AutoPairsClosedPairs = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function! AutoPairsInsert(key)
|
function! AutoPairsInsert(key)
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
@ -81,6 +84,17 @@ function! AutoPairsJump()
|
|||||||
call search('[{("\[\]'')}]','W')
|
call search('[{("\[\]'')}]','W')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! AutoPairsExtend()
|
||||||
|
let line = getline('.')
|
||||||
|
let current_char = line[col('.')-1]
|
||||||
|
|
||||||
|
if has_key(g:AutoPairsClosedPairs, current_char)
|
||||||
|
return "\<ESC>lxh:call AutoPairsJump(line('.'))\<CR>pi"
|
||||||
|
end
|
||||||
|
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! AutoPairsMap(key)
|
function! AutoPairsMap(key)
|
||||||
execute 'inoremap <silent> '.a:key.' <C-R>=AutoPairsInsert("\'.a:key.'")<CR>'
|
execute 'inoremap <silent> '.a:key.' <C-R>=AutoPairsInsert("\'.a:key.'")<CR>'
|
||||||
endfunction
|
endfunction
|
||||||
@ -91,6 +105,7 @@ function! AutoPairsInit()
|
|||||||
if open != close
|
if open != close
|
||||||
call AutoPairsMap(close)
|
call AutoPairsMap(close)
|
||||||
end
|
end
|
||||||
|
let g:AutoPairsClosedPairs[close] = 1
|
||||||
endfor
|
endfor
|
||||||
execute 'inoremap <silent> <BS> <C-R>=AutoPairsDelete()<CR>'
|
execute 'inoremap <silent> <BS> <C-R>=AutoPairsDelete()<CR>'
|
||||||
|
|
||||||
@ -99,6 +114,7 @@ function! AutoPairsInit()
|
|||||||
execute 'inoremap <silent> <M-n> <ESC>:call AutoPairsJump()<CR>a'
|
execute 'inoremap <silent> <M-n> <ESC>:call AutoPairsJump()<CR>a'
|
||||||
execute 'inoremap <silent> <M-a> <END>'
|
execute 'inoremap <silent> <M-a> <END>'
|
||||||
execute 'inoremap <silent> <M-o> <END><CR>'
|
execute 'inoremap <silent> <M-o> <END><CR>'
|
||||||
|
execute 'inoremap <silent> <M-e> <C-R>=AutoPairsExtend()<CR>'
|
||||||
end
|
end
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user