Sample Header Ad - 728x90

With ed, reach to the next occurrence

1 vote
1 answer
39 views
Consider a file with an AsciiDoc ordered list like this:
. one
+
----
echo hello
# arbitrary lines...
echo world
----
. two
. three
How do you move the code block to some arbitrary place in the list (like two)? In words, I want to "reach from + to the next quad dash". I played with the problem for a bit and can solve in two steps: 1. Get to the start of the code block of the one item: /one/;/----/. 1. Attach the code block to another list item—that is, in ed, move the range from previous line (the +) to the next ---- to the target (two list item in this case): -,/----/m/two/. Which yields:
. one
. two
+
----
echo hello
# arbitrary lines...
echo world
----
. three
But I wonder if there's a nicer way!
Asked by mbigras (3472 rep)
Mar 2, 2025, 07:07 AM
Last activity: Mar 15, 2025, 08:13 AM