4 ms·
Nice article, good to hear ed is not dead. =) You could also just add the text after the matching line. A little simpler and more straight forward. $ cat
by atsaloli 8y ago
Nice article, good to hear ed is not dead. =)
You could also just add the text after the matching line. A little simpler and more straight forward.
$ cat > /tmp/ed-script
/baz
a
- elephants
.
w
q
$ cat /tmp/2
foo:
- bar
- baz
- bananas
$ cat /tmp/ed-script | ed /tmp/2
33
- baz
47
$ cat /tmp/2
foo:
- bar
- baz
- elephants
- bananas
$·
- samatman 8y agoMy guess is that the - is replacing something like an org-mode cookie, which could be in a few states that one might want to preserve.
- fiddlerwoaroof 8y agoI don’t think matches the spec that the new line has the same number of leading spaces as the surrounding lines
- fiddlerwoaroof 8y agoWeird, after rereading the article, it seems like I may have imagined that part.
- bramblerose 8y agoAn older version of the article contained the following: > I had one extra weird requirement which was that some of the lines were indented with 2 spaces, and some with 4 spaces. The - elephant line needed to have the same indentation as the previous line.
- atsaloli 8y agoWell! That explains the .t. Thanks! :)