Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I search for the selected text?

Tags:

vim

How do I search for the selected (with v and y) string? I usually search with /, but I cannot paste the selected string after /.

like image 646
Sungguk Lim Avatar asked Dec 21 '11 08:12

Sungguk Lim


People also ask

How do I search for a specific text on my computer?

Tip: You can also use the keyboard shortcuts Ctrl + f (Windows, Linux, and ChromeOS) or + f (Mac) to find a word or phrase quickly. You can find more info about a specific word or phrase on a page. Highlight a word or phrase. On a PC: Right-click the highlighted content.

How do you search for a certain word in a text?

Hold the Ctrl keyboard key and press the F keyboard key (Ctrl+F) or right-click (click the right mouse button) somewhere on the article and select Find (in this article).

How do I select selected text?

To select a single word, quickly double-click that word. To select a line of text, place your cursor at the start of the line, and press Shift + down arrow. To select a paragraph, place your cursor at the start of the paragraph, and press Ctrl + Shift + down arrow.


2 Answers

In insert mode you can use CTRL-R to insert the contents of Vim registers. By default, copied text gets put in the unnamed register ", so to insert that text you would type <C-R>" in insert mode. The search prompt uses Command-line mode which has its own CTRL-R that works almost identically to the one in Insert mode.

So if I just yanked the text foo, typing /<C-R>" would search for the text foo once I press enter.

like image 170
David Brown Avatar answered Oct 13 '22 21:10

David Brown


:set hls
:vmap * y:let @/ = @"<CR>
  • set hls (hight light search)
  • v => hjkl (select something)
  • press *, copy selected text to reg "
  • set content of reg / as "
  • press n/N to navigate
like image 43
kev Avatar answered Oct 13 '22 21:10

kev