I'm trying to understand the ed
DSL a little bit better because versions of it show up in other tools (e.g. sed
, vim
).
Using ed
it is possible to print the next 4 lines using .,+4n
where .,+4
is an explicit range starting at the current line and extending 4 lines downward.
However, printing several lines around the current one for context seems important enough to deserve some syntactic sugar.
Is there an abbreviation for line ranges relative to the current line in ed
already?
e.g. in the transcript below .,+4n
seems rather long.
$ touch ~/foo
$ ed '-p* ' ~/foo
0
* 0a
1
2
3
4
5
6
7
8
9
10
11
.
* 5
5
* .,+4n
5 5
6 6
7 7
8 8
9 9
.,+4n
and that does more than that? e.g. you do not want-4,+4p
? – Jeff Schaller Nov 10 '18 at 19:53relative to
, as inline ranges relative to the current line
– jsotola Nov 10 '18 at 20:34ed
better, there's an ancient game calledquiz
(in the bsdgames package in my linux distro). The questions and answers for/usr/games/quiz function ed-command
can be instructive. – Cupcake Protocol Nov 11 '18 at 01:15