While doing yank/put while iterating through the rows works fine this can actually be done with a single yank/put thanks to blockwise Visual mode. That is the mode you enter by hitting Ctrl+V from Normal mode.
Since OP is flexible on the format and because some of this is probably new for a lot of folks I'll show a couple methods for joining the text using a Visual block.
Tabular
Personally I like this format which emulates a table; sections separated by a bit of whitespace and the rightmost section left-aligned on a single column...
vivre to live
aimer to like
étudier to study
The feature that makes this possible is called "Virtual editing" which allows some interesting movement with the cursor.
...the cursor can be positioned where there is
no actual character. This can be halfway into a tab or beyond the end
of the line. Useful for selecting a rectangle in Visual mode and
editing a table.
(Emphasis is mine...selecting a rectangle and editing a table is kind of what we'll be doing.)
In this case we'll set the option to "block" which allows virtual editing in blockwise Visual mode: :set ve=block
. Then, with the cursor at the start of the first block (i.e. on the v
in vivre
)...
<C-V>}<BS>ll"adgvVjd"aP
<C-V>
- Ctrl+V to enter blockwise Visual mode
}<BS>
- move to the bottom right of the text block
ll
- pick up a couple extra spaces as padding (this is where virtual editing comes into play)
"ad
- delete the selected text into register a
gvV
- reselect the previously selected visual block and switch to "linewise" mode
jd
- add an extra line to the selection and then delete the selection
"aP
- insert the first block of text before the second block
(At this point you may want to reset virtual edit to its default value: :set ve&
)
Update: I golfed this down to two fewer characters by yanking instead of deleting and taking advantage of the fact that the last yank one does can be found in register 0: <C-V>}<BS>llygvVjd"0P
. I also could have kept the delete and P
ut from register 2 since each delete "pushed" onto a stack of sorts: registers 1-9.
Dash-delimited
If you prefer the dash separation we can also use blockwise Visual mode and we don't even need virtual editing:
mt<C-V>}mb<BS>$A - <Esc>gvd'bjPkd't
Briefly, this will
- Mark the beginning of the first block
- Select the block with blockwise Visual mode, marking the following line in the process.
- Append
-
to all lines
- Reselect the block and delete the contained text
- Go to the second block and
P
ut/prepend the first block
- Using the marks set earlier remove the (now empty) first block lines
The result:
vivre - to live
aimer - to like
étudier - to study
Reuse
If you're saying "But I want macros so I can reuse it" you can create a mapping instead. These are easier to keep in your vimrc, for one thing.
Using the second solution, for example, you'd just copy it straight in to the mapping:
:nnoremap <leader>X mt<C-V>}mb<BS>$A - <Esc>gvd'bjPkd't
(Use whatever keystrokes you want in place of <leader>X
.)