in vs code I have the following file
1
2
3
a
b
c
Now I do the following steps
The result is
1, a
b
c
2, a
b
c
3, a
b
c
but the result I wanted is
1, a
2, b
3, c
Sometime ago this functionality was apparently added. You can simply cut to your clipboard and then paste to multiple cursors - and, if there are the same number of lines on the clipboard as multiple cursors - each cursor will get one line from the clipboard.
You no longer need to be in multi-cursor mode for the cut or however you got the text onto the clipboard. Just cut it.
Demo:
Unfortunately, the gif cut off the full command after selecting the 1,2,3,
. What you then want to do is put a cursor at the end of each line of the selection. Command: Add Cursors to Line Ends
Shift+Alt+I.
VSCode 1.39 added this setting:
Editor: Multi Cursor Paste
Controls pasting when the line count of the pasted text matches the cursor count.
"editor.multiCursorPaste": "spread"
that will do what you want.
There is a second option full
where each cursor will get the entire clipboard text. See https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_39.md#new-option-for-multi-cursor-pasting. Demo of the full
option:
From the multi-cursor paste release notes:
New option for multi cursor pasting
In the past, when pasting multi-line text from the clipboard, VS Code would check if the clipboard text line count matches the cursor count, and if it does, it would "distribute"/"spread" each line to a cursor. This behavior is now tunable via the editor.multiCursorPaste setting, which can have the values:
spread - Each cursor pastes a line of text (default).
full - Each cursor pastes the full clipboard text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With