I have two columns full of text, and I want to get them side-by-side. For example, I have
abc
def
ghi
and
123
456
789
and I want
123 abc
456 def
789 ghi
All I can find is how to paste the same line onto the end of every line in a column. I can't figure out how to paste a multi-line block of text on the end of another column.
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).
I was wondering why "visual block mode" wasn't working for me. The key is to yank (or delete) in visual mode.
I find myself needing to copy some stuff from excel columns having variable lengths. Here's how I do it:
Names
Donald Knuth
Sebastian Thrun
Peter Norvig
Satoshi Nakamoto
Age
100
50
60
45
Let's say you want to put the second column after the first.
Age
Ctrl + v
to enter visual mode5
in 45
y
to yank (or d
to delete)You have now yanked in visual mode.
Paste (in normal mode)
Move to the end of the first line and add more spaces because it's shorter than the second line for example. If you paste a "block" without adding extra spaces, it will overwrite the "run" in Sebastian Thrun.
Now you're on the first line, insert a few spaces after the last character. Make sure you're not in insert mode and hit p
to paste the block. (If you want to paste in insert mode, use ctrl+r "
)
Use visual block (ctrl-v
) to cut the letter column. Then move to the first line of the number column. Move to the end and make one space. Then paste the letter column.
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