In vim, how do I paste a column of text to the end of irregular length lines?
You can do it like this:
- Start on the first line of the second block
qq
, start recording theq
macro4k
, go up four linesd$
, delete till the end of line4j
, go back to the previous line$p
, paste the line at the end of the lineq
, stop recording the macrojVG
, go down one line and select the remaining lines:norm! @q
, apply the macro to the selection
It does however leave space where the previous text was. @Kent one's is still easier.
My UnconditionalPaste plugin has (among others) gBp
/ gBP
mappings that paste register contents as a minimal fitting (not rectangular) block with a jagged right edge.
demo
You could try to do the following four steps:
- block-wise select the first 3 lines (you want to paste later), and press
y
- line-wise select (
V
) the 3 lines ending with_
, press:right
- then move cursor to the end of the first line(
$
), paste the yanked text gv
re-select the lines, press:left
It looks like this:
Step 1
- goto to the start of the SPP... lines, then start Visual mode linewise with V (capital V), press j two times to get the desired lines selected then press y.
Step 2
- goto the start of the TIL0... lines, then start Visual mode linewise with V (capital V), press j two times to get the desired lines selected then type...
:s;$;\=' ' . split(@")[line('.')-line("'<")];g`
and press Enter.