[wellylug] vi(m) question.

Sam Cannell sam at plaz.net.nz
Fri May 7 20:25:40 NZST 2004


Do you want it added before or after the space?

If the file is:

1   this is the first line
2   this is the second line
3   another line
4   this is the last line

(line numbers added by vim, not me)

If you want it added before the space, then:

:%s/^/newtext/

And you have:

1 newtext  this is the first line
2 newtext  this is the second line
3 newtext  another line
4 newtext  this is the last line

If you want it added after:

:%s/^\( *\)/\1newtext/

Produces:

1   newtextthis is the first line
2   newtextthis is the second line
3   newtextanother line
4   newtextthis is the last line

HTH,

Sam

-----Original Message-----
From: wellylug-admin at lists.naos.co.nz
[mailto:wellylug-admin at lists.naos.co.nz] On Behalf Of Enkidu
Sent: Friday, 7 May 2004 7:40 p.m.
To: wellylug at lists.naos.co.nz
Subject: [wellylug] vi(m) question.


I want to add something to the start of every line. Every line starts
with white space eg
[snip]




More information about the wellylug mailing list