nvi strangeness

Peter Jeremy peterjeremy at optushome.com.au
Fri Feb 8 21:18:10 UTC 2008


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

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.

-- 
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20080208/1581f88a/attachment.pgp


More information about the freebsd-hackers mailing list