Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 Feb 2008 08:18:02 +1100
From:      Peter Jeremy <peterjeremy@optushome.com.au>
To:        Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= <des@des.no>
Cc:        hackers@freebsd.org
Subject:   Re: nvi strangeness
Message-ID:  <20080208211802.GJ4008@server.vk2pj.dyndns.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

--m46qSNjkc66Ye11q
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Feb 08, 2008 at 11:28:42AM +0100, Dag-Erling Sm=F8rgrav 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)

It definitely would be nice if vi(1) documented the various [foo] terms
it uses and included explicit pointers to /usr/share/doc/{12.vi,13.viref}
instead of just hinting that they exist.

>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"

Actually, ',s/foo/bar/' is illegal in sed ('s/foo/bar/' means every
line).  That means the same syntax means three different things in
three different editors.

>I would really like nvi to understand ed-like ranges, and vi(1) to
>either document this or cross-reference ed(1).

Given that a bare comma means different things in ed and vi, I don't
think that the meanings can be aligned because it would cause too much
pain.  Comparing the various behaviours, IMHO, the ed ',s/foo/bar/'
behaviour is the anomoly: In vi, a null address in a range is the
current line ('.' in ed).  In both ed and sed, a null address in a
range is illegal, except that two null addresses in ed refer to the
entire file.

--=20
Peter Jeremy
Please excuse any delays as the result of my ISP's inability to implement
an MTA that is either RFC2821-compliant or matches their claimed behaviour.

--m46qSNjkc66Ye11q
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (FreeBSD)

iD8DBQFHrMcK/opHv/APuIcRAmVEAJ96gAZ7Qie/QSXv4TsLRH0B6PnoEACeMswq
3u9/P01/gVmWFASwq1dYRiY=
=U/tz
-----END PGP SIGNATURE-----

--m46qSNjkc66Ye11q--



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