" Vim plugin to provide multiline analogs to t & f if !exists('g:supert_provide_bindings') let g:supert_provide_bindings = 1 endif let s:last = [] let s:last_char = '' function! s:getchar() echom "Is not repeating? " . string(! exists('v:repeating') || ! v:repeating) if ! exists('v:repeating') || ! v:repeating let s:last_char = nr2char(getchar()) endif return s:last_char endfunction function! s:do_search(type, vis) abort if a:type == ';' call s:do_last(0, a:vis) elseif a:type == ',' call s:do_last(1, a:vis) else call s:do_search_ch(a:type, a:vis, s:getchar()) endif endfunction function! s:do_last(inv, vis) abort if len(s:last) < 2 return endif let type = s:last[0] let ch = s:last[1] if a:inv if type =~ '[a-z]' let type = toupper(type) else let type = tolower(type) endif endif return s:do_search_ch(type, a:vis, ch) endfunction function! s:do_search_ch(type, vis, ch) let s:last = [a:type, a:ch] let flags = 'W' let pattern = '' if a:type =~ '[A-Z]' let flags .= 'b' endif let pattern = a:ch if a:type == 't' let pattern = '\zs\_.\ze' . pattern elseif a:type == 'T' let pattern = pattern . '\zs\_.\ze' endif let i = 0 while i < v:count1 call search(pattern, flags) let i += 1 endwhile endfunction nnoremap (supert-replace-t) call do_search('t', '') nnoremap (supert-replace-T) call do_search('T', '') nnoremap (supert-replace-f) call do_search('f', '') nnoremap (supert-replace-F) call do_search('F', '') vnoremap (supert-replace-t) call do_search('t', 'v') vnoremap (supert-replace-T) call do_search('T', 'v') vnoremap (supert-replace-f) call do_search('f', 'v') vnoremap (supert-replace-F) call do_search('F', 'v') onoremap (supert-replace-t) call do_search('t', 'o') onoremap (supert-replace-T) call do_search('T', 'o') onoremap (supert-replace-f) call do_search('f', 'o') onoremap (supert-replace-F) call do_search('F', 'o') onoremap (supert-replace-,) call do_search(',', 'o') onoremap (supert-replace-;) call do_search(';', 'o') vnoremap (supert-replace-,) call do_search(',', 'v') vnoremap (supert-replace-;) call do_search(';', 'v') nnoremap (supert-replace-,) call do_search(',', '') nnoremap (supert-replace-;) call do_search(';', '') if g:supert_provide_bindings nnoremap (supert-replace-t) nnoremap (supert-replace-T) nnoremap (supert-replace-f) nnoremap (supert-replace-F) vnoremap (supert-replace-t) vnoremap (supert-replace-T) vnoremap (supert-replace-f) vnoremap (supert-replace-F) onoremap (supert-replace-t) onoremap (supert-replace-T) onoremap (supert-replace-f) onoremap (supert-replace-F) vnoremap (supert-replace-;) vnoremap (supert-replace-,) nnoremap (supert-replace-;) nnoremap (supert-replace-,) onoremap (supert-replace-;) onoremap (supert-replace-,) endif