To add to Ian's reference. "Ed Mastery" is the only book I know specific to
ed(1).

Mo

On Thu, 4 Jul 2019, 6:54 pm ropers <rop...@gmail.com wrote:

> Do I understand correctly that this is in reference to these parts of man
> 1 ed:
>
> > /re/
> >    The next line containing the regular expression re. The search wraps
> to the beginning of the buffer and continues down to the current line, if
> necessary. “//” repeats the last search.
>
> > ?re?
> >    The previous line containing the regular expression re. The search
> wraps to the end of the buffer and continues up to the current line, if
> necessary. “??” repeats the last search.
>
> and:
>
> > (1,$)g/re/command-list
> >    Applies command-list to each of the addressed lines matching a
> regular expression re. The current address is set to the line currently
> matched before command-list is executed. At the end of the g command, the
> current address is set to the last line affected by command-list. If no
> lines were matched, the current line number remains unchanged.
> >
> >    Each command in command-list must be on a separate line, and every
> line except for the last must be terminated by a backslash (‘\’). Any
> commands are allowed, except for g, G, v, and V. A newline alone in
> command-list is equivalent to a p command.
>
>
> If yes, then the corresponding parts of ed.1 are:
>
> .It / Ns Ar re Ns /
> The next line containing the regular expression
> .Ar re .
> The search wraps to the beginning of the buffer and continues down to the
> current line, if necessary.
> .Qq //
> repeats the last search.
> .It Pf ? Ar re ?
> The previous line containing the regular expression
> .Ar re .
> The search wraps to the end of the buffer and continues up to the
> current line, if necessary.
> .Qq ??
> repeats the last search.
>
> and:
>
> .It Xo
> .Pf (1,$) Ic g No /
> .Ar re No / Ar command-list
> .Xc
> .Sm on
> Applies
> .Ar command-list
> to each of the addressed lines matching a regular expression
> .Ar re .
> The current address is set to the line currently matched before
> command-list is executed.
> At the end of the
> .Ic g
> command, the current address is set to the last line affected by
> command-list.
> If no lines were matched,
> the current line number remains unchanged.
> .Pp
> Each command in
> .Ar command-list
> must be on a separate line,
> and every line except for the last must be terminated by a backslash
> .Pq Sq \e .
> Any commands are allowed, except for
> .Ic g ,
> .Ic G ,
> .Ic v ,
> and
> .Ic V .
> A newline alone in command-list is equivalent to a
> .Ic p
> command.
> .Sm off
>
> I'm not actually sure how to rewrite that. Would this call for
> separate /re, ?re and (1,$)g/re entries, or would it suffice to say
> that the second question mark or slash can be omitted if immediately
> followed by a newline?
>
> Does anyone else have any ideas?
>
> NB: In case people haven't seen it, here's an excellent ed(1)
> tutorial: https://sanctum.geek.nz/arabesque/actually-using-ed/
> I just thought I'd mention that.
>
> Ian
>
> On 03/07/2019, mazoc...@disroot.org <mazoc...@disroot.org> wrote:
> > Hi!
> >
> > I am not good at explaining something shortly and clearly to fit into
> > proper documentation, so I'll just describe my experience here.
> >
> > Terminating regular expressions with / or ? is necessary only if they
> > are followed by commands, otherwise the following are legal in both
> > OpenBSD ed, Plan 9 ed and GNU ed:
> > /something
> > /
> > ?
> > g/ing
> >
> > I hope I made life of many ed users easier :)
> >
> >
>
>

Reply via email to