If you're using Vim then you'll have the visual mode, which is like selecting, but with the separating modes thing that's the basis of vi/vim.
What you want to do is use visual mode to select the source, then yank, then use visual mode again to select the scope of the destination, and then paste to text from the default buffer.
Example:
In a text file with:
1| qwer
2| asdf
3| zxcv
4| poiu
with the following sequence: ggVjyGVkp
you'll end with:
1| qwer
2| asdf
3| qewr
4| asdf
Explained:
gg
: go to first line
V
: start visual mode with whole lines
j
: go down one line (with the selection started on the previous lines this grows the selection one line down)
y
: yank to the default buffer (the two selected lines, and it automatically exits you from visual mode)
G
: go to the last line
V
: start visual mode (same as before)
k
: go up one line (as before, with the visual mode enabled, this grows the selection one line up)
p
: paste (with the selection on the two last lines, it will replace those lines with whatever there is in the buffer -- the 2 first lines in this case)
This has the little inconvenient that puts the last block on the buffer, so it's somehow not desired for repeated pastings of the same thing, so you'll want to save the source to a named buffer with something like "ay
(to a buffer called "a") and paste with something like "ap
(but then if you're programming, you probably don't want to paste several times but to create a function and call it, right? RIGHT?).
If you are only using vi, then youll have to use invisible marks instead the visual mode, :he mark
for more on this, I'm sorry but I'm not very good with this invisible marks thing, I'm pretty contaminated with visual mode.