Multiline column copy paste in VS Code
Is it possible to do pasting in multiline editing (cursor |):
text1 = [|]
text2 = [|]
text3 = [|]
text4 = [|]
Assuming I have pasted the following lines:
val1
val2
val3
val4
I would like to have this result:
text1 = [val1]
text2 = [val2]
text3 = [val3]
text4 = [val4]
What actually happens is that the clipboard content is pasted four times, once for each cursor.
Something like mentioned in this answer, but instead of typing simply pasting: https://stackoverflow.com/a/30039968/1374488
Use column-edit instead of the multi-line edit mode:
- Click the end of the source text.
- Shift Alt, click the beginning.
- Copy.
- Click the end of the destination text.
- Shift Alt, click the beginning.
- Paste.
I had some trouble with this until I figured it out. The second selection ( where you want to paste ), must be the same length as the first selection, otherwise it pastes all items at each location ( instead of one item per row ).
I had to do this for hundreds of lines, mapping db columns. What I ended up doing to speed this is was creating an excel sheet with 3 columns:
COL1 COL2 COL3
text1 = [ val1 ]
text2 = [ val2 ]
text3 = [ val3 ]
text4 = [ val4 ]
And then searching and replacing tabs.