[wellylug] vi(m) question.

Enkidu enkidu at cliffp.com
Sat May 8 11:21:30 NZST 2004


On Fri, 7 May 2004 23:57:20 +1200, you wrote:

>1    first line
>2    second line
>3 third line and we want to leave this alone
>4    fourth line
>5    fifth line
>6 sixth line and this stays the same too.
>
>:%s/^\( \+\)/newtext\1/
>
>1 newtext   first line
>2 newtext   second line
>3 third line and we want to leave this alone
>4 newtext   fourth line
>5 newtext   fifth line
>6 sixth line and this stays the same too.
>
>If you use '\s' instead of ' ', it'll match other whitespace characters
>like tabs: 
>
>:%s/^\(\s\+\)/newtext\1/
>
>There may be characters other than space and tab that it matches - I
>don't remember off the top of my head. :)
>

Thanks for that. I think the major problem was using \w when I meant
\s!

I guess that "\1" in the second half means "everything in the ( ) from
the first part". 

The first bit means "at the start of the string remember everything
including the white space but what does "\+\" mean?

Cheers,

Cliff




More information about the wellylug mailing list