Skip to main content
deleted 58 characters in body
Source Link
slm
  • 379.8k
  • 127
  • 793
  • 897

vi vim replace search text by manipulated search text

I'm stucked in a bigger problem. This is a very simplified version of themy problem. Suppose I have a text file containing at several places the code 20091a or 20092a or 20093a. I'm wishing to surround all thesethis code by the text surrounded with <code></code>. So finally theythe resulting strings above would becomebe like 20091a<code>20091a</code> or 20092a<code>20092a</code> or 20093a<code>20093a</code>.

In summary, my question,So how do I replace the search text with a text containing the search text.? Is there any variable which holds the search text so that I could use something like :%s/2009.a/<code>$SEARCH_TEXT<\/div>?

vi replace search text by manipulated search text

I'm stucked in a bigger problem. This is a very simplified version of the problem. Suppose I have a text file containing at several places the code 20091a or 20092a or 20093a. I'm wishing to surround all these code by the text surrounded with . So finally they would become like 20091a or 20092a or 20093a.

In summary, my question, how do I replace the search text with a text containing the search text. Is there any variable which holds the search text so that I could use something like :%s/2009.a/<code>$SEARCH_TEXT<\/div>

vim replace search text by manipulated search text

This is a very simplified version of my problem. Suppose I have a text file containing several places the code 20091a or 20092a or 20093a. I'm wishing to surround all this code by the text <code></code>. So the resulting strings above would be like <code>20091a</code> or <code>20092a</code> or <code>20093a</code>.

So how do I replace the search text with text containing the search text? Is there any variable which holds the search text so that I could use something like :%s/2009.a/<code>$SEARCH_TEXT<\/div>?

Source Link
Noor
  • 1k
  • 4
  • 14
  • 19

vi replace search text by manipulated search text

I'm stucked in a bigger problem. This is a very simplified version of the problem. Suppose I have a text file containing at several places the code 20091a or 20092a or 20093a. I'm wishing to surround all these code by the text surrounded with . So finally they would become like 20091a or 20092a or 20093a.

In summary, my question, how do I replace the search text with a text containing the search text. Is there any variable which holds the search text so that I could use something like :%s/2009.a/<code>$SEARCH_TEXT<\/div>