Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 08 Feb 2008 11:28:42 +0100
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        hackers@freebsd.org
Subject:   nvi strangeness
Message-ID:  <86prv7agit.fsf@ds4.des.no>

next in thread | raw e-mail | index | archive | help
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"

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

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
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86prv7agit.fsf>