diff --git a/autoload/matchup.vim b/autoload/matchup.vim index 7a5b348..48b2245 100644 --- a/autoload/matchup.vim +++ b/autoload/matchup.vim @@ -126,6 +126,8 @@ function! s:init_default_mappings() call s:map('o', l:opforce.'z%', \ '(matchup-o_'.l:opforce.')(matchup-z%)') endfor + + call s:map('i', '%', '(matchup-c_g%)') endif if get(g:, 'matchup_text_obj_enabled', 0) @@ -201,6 +203,9 @@ function! s:motion_init_module() " {{{1 onoremap (matchup-z%) \ :call matchup#motion#op('z%') + inoremap (matchup-c_g%) + \ :call matchup#motion#insert_mode() + call matchup#perf#toc('loading_module', 'motion') endfunction diff --git a/autoload/matchup/motion.vim b/autoload/matchup/motion.vim index cbb69eb..d2ef2ee 100644 --- a/autoload/matchup/motion.vim +++ b/autoload/matchup/motion.vim @@ -256,6 +256,25 @@ function! matchup#motion#jump_inside(visual) " {{{1 call matchup#pos#set_cursor(l:new_pos) endfunction +" }}}1 +function! matchup#motion#insert_mode() " {{{1 + call matchup#perf#timeout_start(0) " disable the timeout + + let l:delim = matchup#delim#get_current( + \ 'all', 'both_all', {'insertmode': 1}) + if empty(l:delim) | return | endif + + let l:matches = matchup#delim#get_matching(l:delim, 1) + if len(l:matches) <= (l:delim.side ==# 'mid' ? 2 : 1) | return | endif + if !has_key(l:delim, 'links') | return | endif + let l:delim = get(l:delim.links, 'next', {}) + if empty(l:delim) | return | endif + + let l:new_pos = [l:delim.lnum, l:delim.cnum] + let l:new_pos[1] += matchup#delim#end_offset(l:delim) + call matchup#pos#set_cursor(matchup#pos#next_eol(l:new_pos)) +endfunction + " }}}1 let &cpo = s:save_cpo