[wellylug] vi(m) question.

Enkidu enkidu at cliffp.com
Fri May 7 22:04:45 NZST 2004


On Fri, 7 May 2004 20:25:40 +1200, you wrote:

>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/
>
Ah buggerme! 
>
>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
>
What if *some* of the lines already had something there?

1   first line
2   second line
3third line and we want to leave this alone
4   fourth line
5   fifth line
6sixth line and this stays the same too.

into -->

1right   first line
2right   second line
3third line and we want to leave this alone
4right   fourth line
5right   fifth line
6sixth line and this stays the same too.

How's this?

%s/^\w/right /iga  ??

I think I tried that and it didn't work. Obviously, I can keep trying,
but if anyone has any ideas.... they'd be appreciated.

Cheers,

Cliff




More information about the wellylug mailing list