0

I search a way to paste/merge 2 block of text

block A

apple
pear
banana

block B

tomato
beans
potato

to this

apple tomato
pear beans
banana potato

I'm looking for an easy way to do this using macros.

1

Visual block mode is a good route....

  1. Put cursor on "a" in apple
  2. <C-V> : we'll visually select the whole block...
  3. move cursor to banana, e.g. }k is good (line count agnostic)
  4. $A<space><esc> - this adds a space after every line
  5. gvd - gv recreates the previous visual selection, d deletes

Move cursor to "t" in tomato and hit P to paste.

This can be used directly in a macro.

Update: I just remembered that I wrote a fairly substantial answer to a somewhat similar question: Add a block of text to end of lines. It doesn't have an exact answer to your question like I've written here but you might find it useful/interesting.

| improve this answer | |
  • I tried that but when I paste I end up with, is it something wrong with my paste command? tomato apple pear banana beans potato – Matheus Campos Jun 30 at 21:23
  • You pasted with capital P? Cursor first column, first line of second block? – B Layer Jun 30 at 21:25
  • if i use capital p it goes apple pear banana tomato beans potato – Matheus Campos Jun 30 at 21:26
  • I got it here... tks – Matheus Campos Jun 30 at 21:28
  • 1
    While that configuration's good for debugging problems it's not really representative of the most common setups. A better test would probably be to use Vim's defaults.vim as the sole config file. Just use --clean. Either way when I get a sec I'll see if I can reproduce what you're seeing. – B Layer Jun 30 at 23:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.