nvi strangeness
Julian Elischer
julian at elischer.org
Fri Feb 8 20:55:53 UTC 2008
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
More information about the freebsd-hackers
mailing list