incsearch.vim を使いたいと思っているけれど、標準のインクリメンタルサーチの場合にできていることを同様に実現する方法がわかっていないので移行できていない。
実現方法がわからないのは、下記のようなこと。
検索結果を置換用に流用
インクリメンタルサーチを実行中に <C-t> で検索文字列を置換用に流用している。
" https://raw.githubusercontent.com/cohama/.vim/master/.vimrc
" / と :s///g をトグルする {{{
cnoremap <expr> <C-t> ToggleSubstituteSearch(getcmdtype(), getcmdline())
function! ToggleSubstituteSearch(type, line)
if a:type ==# '/' || a:type ==# '?'
let range = GetOnetime('s:range', '%')
return "\<End>\<C-U>\<BS>" . substitute(a:line, '^\(.*\)', ':' . range . 's/\1', '')
elseif a:type ==# ':'
let g:line = a:line
let [s:range, expr] = matchlist(a:line, '^\(.*\)s\%[ubstitute]\/\(.*\)$')[1:2]
if s:range ==# '''<,''>'
call setpos('.', getpos('''<'))
endif
return "\<End>\<C-U>\<BS>" . '/' . expr
endif
endfunction
function! GetOnetime(varname, defaultValue)
if !exists(a:varname)
return a:defaultValue
endif
let varValue = eval(a:varname)
execute 'unlet ' . a:varname
return varValue
endfunction
" }}}
クリップボードからの貼付け
/ 押下後にクリップボードから貼り付けてインクリメンタルサーチに使っている