RoyalPie717
RoyalPie717

Reputation: 719

How do I find text with yanked text on vim?

Let us say that I yanked the following word: Cheese. Now I want to find Cheese within a text document. I hit the forward slash key(/)... and this is where I end. Is there a way to search with Yanked word? Also, is there a way you can use yanked words in substitution(s:/yanked/beef/g)?

Upvotes: 71

Views: 14275

Answers (2)

klchow916
klchow916

Reputation: 420

  1. yank the text
  2. press q/pEnter

q/: open the search history

pEnter: paste the yanked text on the command line and search

Upvotes: 36

Christian C. Salvadó
Christian C. Salvadó

Reputation: 827198

The most recently yanked text will be stored in the 0 and " registers (if no register was explicitly specified e.g. by "xy).

Then you can paste the text of any that register in the last line (either in search mode / or in last line command mode : ) with Ctrl-RX, where X is the register you want to paste.

For example:

/Ctrl-R0

Will paste the contents of the register 0 in the forward search command pattern.

Upvotes: 134

Related Questions