I want to
This has been explained in Search for selection in vim.
vy/<C-r>0 (Ctrlr+0):h i_ctrl-r (thanks to romainl in the comments)Another example is using the command line:
vyq/p, and search by pressing EnterIn short: yq/p<Enter>
Oh, mate, actually you can use the mighty Visual Search originated by the author of the book Practical Vim. It's very lightweight!
Simply add following stuff into your vimrc,
xnoremap * :<C-u>call <SID>VSetSearch()<CR>/<C-R>=@/<CR><CR>
xnoremap # :<C-u>call <SID>VSetSearch()<CR>?<C-R>=@/<CR><CR>
function! s:VSetSearch()
let temp = @s
norm! gv"sy
let @/ = '\V' . substitute(escape(@s, '/\'), '\n', '\\n','g')
let @s = temp
endfunction
Visual select the content you want to do search, then press the star key *, Voila !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With