How to insert code in multiple lines in a multiple lines code?
edit, editor, emacs, vim
Solution
You should select the top left corner with the cursor, type Control+V, then go to last line, and type $ to get the end of all lines (this was missed in other answers). Then you delete with d, go to the destination, and use p.
For you exact sample, the solution in vim is:
G0<c-v>{j$dggf(p
Decomposed as:
G go to last line of file
0 go to its first character
<c-V> to start a blockwise selection
{ go to previous empty line
j go to next line (hence the beginning of block)
$ extend the blockwise selection to end of ALL lines (that was my point)
d delete and store the block
gg go to first line of file
f( go to next character '(' if on same line.
p to paste the block after the column of current character.
An alternative to $ is to enable
:set virtualedit=all
and that will do the job if you cannot put the cursor at the destination (when beyond end of its line).
Problem
I'm doing some cut and paste from a lot of different data sources. I'm trying to insert code in multiple lines in a multiple line code so that for the first line of the pasted code go between two specific points of the original code and the same for the second and so on. It's something like insert blocks of code between splitted multiple lines of code. The picture .gif below show what I mean: How can I do that? I'm trying with VIM CTRL+V but I can't paste multi lines code. Here is the sample: ``` VIOLET=SpectralBand([0.380,0.450],'violet') BLUE= SpectralBand([0.450,0.495],'b') GREEN= SpectralBand([0.495,0.570],'g') YELLOW=SpectralBand([0.570,0.590],'y') ORANGE=SpectralBand([0.590,0.620],'orange') RED= SpectralBand([0.620,0.750],'r') "viol3et", 45839, "bl3ue" , 43903, "gre3en" , 28392, "y3ellow", 23049, "o3range", 12389, "r3ed" , 32840, ```