If I've selected some text in visual mode, how do I insert the selected text into the command line?
For example, if I want to search for the currently selected text, I could use y/<c-r>"
… But is there some way of doing it without first yanking the selected text?
Edit: A better example, as searching while in visual mode would expand the selection: if I've got part of a file name selected, and I want append to that name then open it in a new editor.
Press y to copy, or d to cut the selection. Move the cursor to the location where you want to paste the contents. Press P to paste the contents before the cursor, or p to paste it after the cursor.
Press v to begin character-based visual selection, or V to select whole lines, or Ctrl-v or Ctrl-q to select a block. Move the cursor to the end of the text to be cut/copied. While selecting text, you can perform searches and other advanced movement. Press d (delete) to cut, or y (yank) to copy.
Yes. Hit Ctrl - R then " . If you have literal control characters in what you have yanked, use Ctrl - R , Ctrl - O , " .
I have remapped :
in visual mode to solve this problem. With following mapping I can paste selected text to the command line and b - onus - move the cursor to the leftmost position:
vnoremap : y:<C-r>"<C-b>
One small drawback I can see - pressing :
now cancels the selection.
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