Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find text with yanked text on vim?

Tags:

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)?

like image 470
RoyalPie717 Avatar asked Jul 23 '10 04:07

RoyalPie717


People also ask

How do I replace a word with yanked in Vim?

Move the cursor to another word (say "third"). Repeat the operation (change word and replace it with "first"). Move the cursor to another word and press . to repeat the change. Yank inner text (text containing cursor which is in quotes).

How do I yank text in Vim?

Copying (Yanking) To copy text, place the cursor in the desired location and press the y key followed by the movement command. Below are some helpful yanking commands: yy - Yank (copy) the current line, including the newline character.

How do I yank to clipboard in Vim?

Below steps explains how to yank. In vim command mode press v , this will switch you to VISUAL mode. Move the cursor around to select the text or lines you need to copy. Press y , this will copy the selected text to clipboard.

How do I paste a yanked line in Vim to Notepad?

In Vim, Copying is done using the y or "yanking". To copy selected text to system clipboard type "+y in Normal Mode. Now you can paste it anywhere else using Ctrl-v .


2 Answers

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.

like image 74
Christian C. Salvadó Avatar answered Oct 06 '22 08:10

Christian C. Salvadó


  1. yank the text
  2. press q/pEnter

q/: open the search history

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

like image 25
klchow916 Avatar answered Oct 06 '22 08:10

klchow916