onoremap a% Vcall search('{') normal! % onoremap i% call search() normal! v%o vnoremap a% V/{% vnoremap i% /{v%oo " " anb, anB, an<, an[ " " "Next" objects. These objects are like ab, aB, a<, a[, etc. but will always go to the next body " regardless of if it is nested or not. " " If outside an expression, the behavior is the " onoremap anb call inner_next(v:operator, 'a', '(', ')') onoremap inb call inner_next(v:operator, 'i', '(', ')') vnoremap anb call inner_next(v:operator, 'a', '(', ')') vnoremap inb call inner_next(v:operator, 'i', '(', ')') onoremap anB call inner_next(v:operator, 'a', '{', '}') onoremap inB call inner_next(v:operator, 'i', '{', '}') vnoremap anB call inner_next(v:operator, 'a', '{', '}') vnoremap inB call inner_next(v:operator, 'i', '{', '}') onoremap an< call inner_next(v:operator, 'a', '<', '>') onoremap in< call inner_next(v:operator, 'i', '<', '>') vnoremap an< call inner_next(v:operator, 'a', '<', '>') vnoremap in< call inner_next(v:operator, 'i', '<', '>') onoremap an[ call inner_next(v:operator, 'a', '\[', '\]') onoremap in[ call inner_next(v:operator, 'i', '\[', '\]') vnoremap an[ call inner_next(v:operator, 'a', '\[', '\]') vnoremap in[ call inner_next(v:operator, 'i', '\[', '\]') function! s:inner_next(operator, ai, open, close) abort let opos = getpos('.') let i = 0 while i < v:count + 1 call search(a:open) let i += 1 endwhile normal! % if (getline('.')[col('.')-1] =~ a:open) normal! % endif if col('.') > 1 && (getline('.')[col('.')-2] =~ a:open) && a:ai == 'i' if v:operator =~ "[cd]" " Cheese a 0-width by inserting a space to then immediately delete for d and c operators. exec "normal! i \v" else " Other operations, just reset the position to what it was before. call setpos('.', opos) endif return endif if a:ai == 'i' exec "normal! \v%\o\" else exec "normal! \v%" endif endfunction