I'm looking for an approach, in Vimscript, to operate on the text lines of a buffer by looping through lines of a visual selection.
Specifically, my goal is very simple: I have a (vertical) list of words, which I want to convert into a table; the first word is in the first column, the second is the first word in the second column; the third word is the second word in the first column, the fourth is the second word in the second column; and so on.
So, for the vertical list of letters below, I want to achieve this (in verbatim):
a --> 1. a b b 2. c d c 3. e f d e f
My initial thought was to find a way to loop over the lines of a visual selection, after which I apply a macro depending on the whether the current linenumber is even or odd. The iterator variable of the loop can then be used to insert the row numbers.
How does one loop through the lines of a visual selection and operate on the current line, through a Vimscript function?