Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 08 Feb 2008 12:55:57 -0800
From:      Julian Elischer <julian@elischer.org>
To:        =?UTF-8?B?RGFnLUVybGluZyBTbcO4cmdyYXY=?= <des@des.no>
Cc:        hackers@freebsd.org
Subject:   Re: nvi strangeness
Message-ID:  <47ACC1DD.8010105@elischer.org>
In-Reply-To: <86prv7agit.fsf@ds4.des.no>
References:  <86prv7agit.fsf@ds4.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help
Dag-Erling Smørgrav wrote:
> As everybody knows, the ex/vi command for regexp substitution is
> 
>        [range] s[ubstitute] [/pattern/replace/] [options] [count] [flags]
> 
> The man page does not document the syntax for ranges (nor for offsets or
> counts for that matter)
> 
> Assuming the syntax is the same as for ed / sed, the following should
> replace every occurrence of the word wait with the word delta:
> 
> :,s/\<wait\>/delta/g
> 
> where "," means "the entire file"

the symbol for end of file is $
so 1,$


> 
> That doesn't work, however, and neither does "1,"; only "X,Y" works, so
> if you want to substitute in the entire file, you first have to find out
> how long it is, then manually type in that number.
> 
> ...or you could use the following (courtesy of roberto@):
> 
> :%s/\<wait\>/delta/g

:g/pattern/s//replacement/g
:1,$s/patter/replacement/g

> 
> None of this is documented anywhere.
> 
> I would really like nvi to understand ed-like ranges, and vi(1) to
> either document this or cross-reference ed(1).
> 
> Going off on a tangent, I wonder why the nvi license is reproduced in
> the man page, as it doesn't seem to require it, and no other man page
> includes the license of the program it describes (with a single
> exception: groff)
> 
> DES




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47ACC1DD.8010105>