1

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/;/----/.
  2. 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!

0

1 Answer 1

1

As long as we know we're moving the contents of a specific "source" list item down to an existing "target" list item, we can use /one/; to locate the source line, then move the next few lines, until the line above the next list item to the target with +,/^\./- m /two/.

,n 1 . one 2 + 3 ---- 4 echo hello 5 # arbitrary lines... 6 echo world 7 ---- 8 . two 9 . three 
/one/; +,/^\./- m/two/ 
,n 1 . one 2 . two 3 + 4 ---- 5 echo hello 6 # arbitrary lines... 7 echo world 8 ---- 9 . three 

If you want to move contents down one list item from one to the next, use

/one/; +,/^\./- m // 

Unless I was trying to create an automatic editing script, I would have figured out the line numbers (with the n command), then moved them with 2,7 m 8.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.