Check this Vim tip: Search for visually selected text
Or you can simply yank the selected text with y and go to search mode /, then you can paste the last yanked text with Ctrl+R 0
Explanation
q/ works similarly to vanilla search / except you're in command mode so p actually does "paste" instead of typing the character p. So the above will copy the text you're searching for and paste it into a search.
For more details type :help q/
Use q / instead of just /. (Same with q :). Now you can VIM-edit through your command and search history! (Try Ctrl-N and Ctrl-P sometime).
I just learned (through the excellent book Practical Vim) that there is a plugin for that. You can find the plugin on GitHub.
The plugin lets you search for a visual selection with * and #.
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