lukas_o
lukas_o

Reputation: 4236

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

Upvotes: 72

Views: 62763

Answers (8)

Trần Độ
Trần Độ

Reputation: 51

select all the code u need to copy, then use arrow key move the pointers up to the destination place. The key of way is you move a whole of pointer, not to make another pointer

Upvotes: 0

Kezia wahome
Kezia wahome

Reputation: 1

Install the "Edit csv" extension by Janisdd if you haven't already. This extension provides an Excel-like interface for editing CSV files

At the top right of the Vscode you will see "Edit csv" . This allow you to view the csv file as a table on VScode

This will allow you to manually manipulate the csv with so much ease

The extension also has more advanced use cases like filtering, sorting, or formatting from the "Edit csv" setting .

Upvotes: 0

belwood
belwood

Reputation: 3779

Use column-edit instead of the multi-line edit mode:

  1. Click the end of the source text.
  2. Shift Alt, click the beginning.
  3. Copy.
  4. Click the end of the destination text.
  5. Shift Alt, click the beginning.
  6. Paste.

When using this method, double check that you're copying the same number of lines as you're selecting in the destination ("## selections" noted in the bottom right each time), otherwise it will paste the entire selection per line.

Upvotes: 78

Vaseem W
Vaseem W

Reputation: 89

  1. Hold ALT + SHIFT Keys together
  2. Select the column fields you would like

Upvotes: 1

mahmoud elgml
mahmoud elgml

Reputation: 311

1-select column of data you want to copy by holding alt+shift+mouse selection box and copy it with ctrl+c

2- select the places you want to paste into with alt+mouse click(note: this helps if the lines to be pasted into are in different places)

3-paste into the selected locations with ctrl+v

Upvotes: 2

Dzmitry Lahoda
Dzmitry Lahoda

Reputation: 939

Worked for me https://github.com/john-guo/columnpaste . Adds Column paste command.

Upvotes: 1

Eli
Eli

Reputation: 1846

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 ).

Upvotes: 21

lukas_o
lukas_o

Reputation: 4236

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.

Upvotes: 1

Related Questions