On Wed, 23 Dec 2020 21:16:20 -0400 John Cordes <[email protected]> wrote:
> One big problem with the first part is that I *only* want to > concatenate the continuation lines when they appear immediately > following a "2 NOTE..." tag, AND that "2 NOTE" tag must be either the > next or next but one line after "2 TYPE tngnote". > > I neglected to make it clear earlier that I need to first search on > "2 TYPE tngnote" since there are other "2 TYPE" tags where I don't > want to change anything. Personally I'd do this as an AWK program (not an AWK one-liner). Have a variable that gets incremented once when you hit "2 NOTE tngnote", gets incremented again when you hit a "2 NOTE" 1 or 2 lines below, and incremented again when you hit "3 CONC". If you increment twice like this, you remove the "3 CONC" from the beginning of the each "3 CONC" line and output it. At the end of the continuations, you put a </div>. This requires that you put the corresponding <div> just before you output the "2 NOTE" line. If, at any time, you hit a line that forecloses the possibility of such line-grafting, you drop the variable back to its original value. It would also be very easy in Python, Python's advantage is that it can easily store lines and "look back" before printing them. AWK can do that, but it's more difficult. I know this is offtopic on this list, but I think any Vim or ex solution that can be made will be fragile and difficult to understand. SteveT Steve Litt Autumn 2020 featured book: Thriving in Tough Times http://www.troubleshooters.com/thrive -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201224150120.72235c5f%40mydesk.domain.cxm.
