In vim, how do I paste a column of text to the end of irregular length lines?

后端 未结 5 1133
悲哀的现实
悲哀的现实 2020-12-30 00:39

I would like to paste a column of text at the end of irregular-length lines.

For example, I would like to paste the following:

SRR447882.fastq.gz
SRR         


        
相关标签:
5条回答
  • 2020-12-30 01:13

    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

    enter image description here

    0 讨论(0)
  • 2020-12-30 01:13

    Here's another way to do it with a different feel to it:

    set ve=all to permit insert/paste at arbitrary columns past eol. Block-copy your source text, then at your first target line paste it with 100|P (100 being any column number longer than your target lines), then :'[,']s, *\%100c,,

    If you do p instead of P you'll get a space separator.

    0 讨论(0)
  • 2020-12-30 01:14

    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.

    0 讨论(0)
  • 2020-12-30 01:25

    You can do it like this:

    • Start on the first line of the second block
    • qq, start recording the q macro
    • 4k, go up four lines
    • d$, delete till the end of line
    • 4j, go back to the previous line
    • $p, paste the line at the end of the line
    • q, stop recording the macro
    • jVG, 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.

    0 讨论(0)
  • 2020-12-30 01:28

    You could try to do the following four steps:

    1. block-wise select the first 3 lines (you want to paste later), and press y
    2. line-wise select (V) the 3 lines ending with _, press :right
    3. then move cursor to the end of the first line($), paste the yanked text
    4. gv re-select the lines, press :left

    It looks like this:

    enter image description here

    0 讨论(0)
提交回复
热议问题