<commit_before>" Replace current word or current selection, following by
" 1. 'n' to next occurance
" 2. '.' to repeat the replacement again
" Useful for replacing a few instances of the term (comparable to multiple cursors).
" nnoremap <silent> <leader>ciw   :let @/='\<'.expand('<cword>').'\>'<CR>cgn
" xnoremap <silent> <leader>c     "sy:let @/=@s<CR>cgn
vnoremap <silent> <Plug>(SearchableChange)  "sy:<C-U>call SearchableChangeAdapter(visualmode(), 1)<CR>
vmap <silent> <leader>c <Plug>(SearchableChange)
nnoremap <leader>c                           :set opfunc=SearchableChangeAdapter<CR>g@
function! SearchableChangeAdapter(type, ...)
    if a:0  " invoked from visual mode, use '< and '> marks.
        let @/ = getreg('s')
        call feedkeys("cgn")
        return
    endif

    let sel_save = &selection
    let &selection = "inclusive"
    if a:type == 'line'
        silent execute 'normal! `[V`]"sy'
    elseif a:type == 'block'
        silent execute 'normal! `[\<C-V>`]"sy'
    else
        silent execute 'normal! `[v`]"sy'
    endif
    let &selection = sel_save
    call SearchableChangeAdapter(visualmode(), 1)
endfunction

" Search for visually selected text, and select the found text
" ref: https://vim.fandom.com/wiki/Search_for_visually_selected_text
xnoremap * y/\V<C-R>=escape(@",'/\')<CR><CR>vgn
xnoremap # y?\V<C-R>=escape(@",'/\')<CR><CR>vgn<commit_msg>vim: add more key mapping for SearchableChange<commit_after>function! OperatorFuncYankS(type)
    let sel_save = &selection
    let &selection = "inclusive"
    if a:type == 'line'
        silent execute 'normal! `[V`]"sy'
    elseif a:type == 'block'
        silent execute 'normal! `[\<C-V>`]"sy'
    else
        silent execute 'normal! `[v`]"sy'
    endif
    let &selection = sel_save
endfunction

" Replace current word or current selection, following by
" 1. 'n' to next occurance
" 2. '.' to repeat the replacement again
" Useful for replacing a few instances of the term (comparable to multiple cursors).
" nnoremap <silent> <Leader>ciw   :let @/='\<'.expand('<cword>').'\>'<CR>cgn
" xnoremap <silent> <Leader>c     "sy:let @/=@s<CR>cgn
vnoremap <silent> <Plug>(SearchableChange)      "sy:<C-U>call SearchableChangeAdapter(visualmode(), 1)<CR>
vmap <silent> <Leader>c                         <Plug>(SearchableChange)
nnoremap <Leader>c                              :set opfunc=SearchableChangeAdapter<CR>g@
nmap <Leader>cc                                 viw<Leader>c
function! SearchableChangeAdapter(type, ...)
    if a:0  " invoked from visual mode, use '< and '> marks.
        let @/ = getreg('s')
        call feedkeys("cgn")
        return
    endif
    call OperatorFuncYankS(a:type)
    call SearchableChangeAdapter(visualmode(), 1)
endfunction

" Search for visually selected text, and select the found text
" ref: https://vim.fandom.com/wiki/Search_for_visually_selected_text
xnoremap * y/\V<C-R>=escape(@",'/\')<CR><CR>vgn
xnoremap # y?\V<C-R>=escape(@",'/\')<CR><CR>vgn
{'fraction_non_alphanumeric': 0.1508736559139785, 'fraction_numerical': 0.003360215053763441, 'mean_word_length': 3.365102639296188, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 55, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4468672', 'n_tokens_mistral': 1050, 'n_tokens_neox': 998, 'n_words': 258}