[lug] VI help

rm at mamma.varadinet.de rm at mamma.varadinet.de
Wed Jul 11 11:55:04 MDT 2001


On Wed, Jul 11, 2001 at 12:48:09PM -0600, Shannon Johnston wrote:
> Hey All,
> I've got a 2,000 line document that I need to add a string to the
> beginning of every line. I know there's a way to do this easily in vi, I
> just don't know how. Can anybody help?

Assuming STRING is the string you want to prepend to each line,
press escape and type the following at the prompt

 1,$ s/^/STRING/ and press enter,

which substitutes the start of the line with string from the
first line (=> 1) to the last line (=> $).
 
> While I'm at it, I have to add a different string to the end of every
> line.

 1,$ s/$/STRING/


  Ralf

> 
> Thanks,
> Shannon
> 
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug



More information about the LUG mailing list