I try to use VIM build my SQL query by concatenate block of strings. For example, I have the following strings in three tabs in VIM:
# block one
where c = '123'
where c = '2345'
...
# block two
set b = 12
set b = 345
...
# block three
update myTable set a = 'abc',
update myTable set a = '23423',
...
each block contains 100 lines (fragments of SQL query). I would like to concatenate those blocks in to one complete SQL query: block one + block two + block three (100 lines) like this:
# sql queries
update myTable set a = 'abc', set b = 12 where c = '123'
update myTable set a = '23423', set b = 345 where c = '2345'
...
Just ignore the first line #..., it is just for explanation. I think that Visual Block can be used do that:
- Yank all the lines in tab "block two";
- Paste buffer to tab "block three" at the beginning;
- Yank all the lines in tab "block one";
- Paste the buffer to tab "block three" at the beginning.
However, I tried to the tip in Visual Block Mode(first two y and p examples), I could not get my expected result. The paste does not concatenate the buffer strings to the block. Not sure what I did wrong. Or any other alternative ways?