Search code examples
vimblockingpaste

gvim paste on multiple rows from external application


I got a block of text in vim with 3 rows with diffrent length. I get another block of data with also 3 rows from an external application (like word or notepad) and I would like to append-paste it on all these 3 rows. I found some posts on this matter https://superuser.com/questions/300362/vim-how-to-paste-a-block-of-text-at-the-end-of-multiple-lines and cut and paste multiple lines in vim (also Paste multiple times) but which only seem to work when the content was originally yanked from vim. clipboard=unnamed is set.

Here is an example what I would like to achieve (stolen from first post ;-D):

//Comment1
//Comment2
//Comment3

datablock from external application

foo = 1;
bar = 2;
baz = 3;

original data

foo = 1; //Comment1
bar = 2; //Comment2
baz = 3; //Comment3

result


Solution

  • You can use my UnconditionalPaste plugin for that. It provides a gbp mapping that forces the paste to be blockwise, regardless of the mode the register was yanked. (It also has other related mappings for characterwise and linewise pastes, and more!)

    With it, position the cursor at the end of the first line, and use "+gbp.