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 SRR447883.fastq.gz SRR447944.fastq.gz
at the end of these lines:
TIL01_ TIL01_ TIL04-TIP285_
Many times in the past, I simply create enough space on the first line that pasting will not come before the end of the existing text in the longest line. But then I need to go back and remove whitespace.
I have tried googling "vim column paste irregular length rows" and similar queries.
Therefore, the key sequence would from command mode, A to get into insert mode at end of line, <space> to insert a space, then Ctrl-v to paste. Alternatively, while in insert mode, use the mouse to put the cursor at the end of a line, <space> then Ctrl-v .
Press Esc, and you'll see you have inserted a column of single spaces. Now use ctrl+v again to highlight the column of spaces. Use p to paste your original column selection.
Pasting over a block of text You can copy a block of text by pressing Ctrl-v (or Ctrl-q if you use Ctrl-v for paste), then moving the cursor to select, and pressing y to yank. Now you can move elsewhere and press p to paste the text after the cursor (or P to paste before).
You could try to do the following four steps:
y
V
) the 3 lines ending with _
, press :right
$
), paste the yanked textgv
re-select the lines, press :left
It looks like this:
You can do it like this:
qq
, start recording the q
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 selectionIt does however leave space where the previous text was. @Kent one's is still easier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With