To get to 'Result' with 'Set 1' and 'Set 2', it isn't just pretty key strokes. That said, I suspect it could be by using a plugin (or perhaps your own function). Such a plugin might be UnconditionalPaste (https://github.com/inkarkat/vim-UnconditionalPaste)
I found this answer, which was helpful and got me going on my solutions: https://vi.stackexchange.com/a/10608/30981
How to get to 'Result':
- Move cursor to line 1 in Set 2, then:
- That moves to start of the line, uses visual mode, selects an additional two lines, selects to the end of each line (but not the newline), and yanks to register 'p' (p being an arbitrary choice).
- If you inspect register p, you will see the type is 'c', meaning characterise.
- This can be converted to blockwise before pasting by manipulation with the setreg() command:
- :call setreg('p','','ab')
- What that does is for register p, append an empty string, and convert the contents to blockwise (basically just converts it to blockwise, you just have to append something to do the operation).
- Now move to the start of Line 1 in Set 1, and paste/prepend before it using 'P'
That should achieve 'Result'.
To get 'Better Result':
- The easiest way is to first do a blockwise insert (Ctrl-V I) for the 3 lines of Set 1 to prepend a space before them, then do the steps above.
- One can also eventually get to it without inserting the blockwise space. This is done using a substitute command, an actual append command to put a space on the last line in the 'p' register, and then do the setreg() conversion to blockwise.
For those that are interested, on the latter approach...For clarity, I'm assigning the output to the 't' register, but you could do all these operations just on 'p' register by altering the commands.
NOTE: the '^J' that you (at least I see) when inspecting a register, actually appears as '^@' when one has finished typing the input sequence into a command, and that input sequence is actually typed literally as
- Once you have yanked Set 2 into register p (as per first part of this solution to get to 'Result'), then:
:let @t = substitute(@p, 'C-v C-j', ' C-v C-j', 'g')
- Which will end up looking like:
:let @t = substitute(@p,'^@',' ^@','g')
- Then, append the space to the last line in the register
:call setreg('t',' ','ac')
- Then, convert it all to blockwise:
- You can then do the 'P' put, to prepend in front of Set 1 in order to get 'Better Result'.
I'm using Neovim 0.5 nightly on Windows 10, your mileage may vary in relation to the whole
Ctrl-v Ctrl-j thing based on version, OS, language....I don't know. All I can say is see this and then experiment a bit: