16

I can select a column in MS Visual Studio code with shift-alt and drag, but how do I paste a column? I can't find that anywhere. The column mode options on the keyboard cheat shortcuts list do not list this.

3 Answers3

14

Column copied using shift + alt can be pasted as a column if you start cursor at exactly same number of lines as that of number of lines in your copied column contents.
Example:
Say the 2nd column in the following text is copied. (it has 2 rows)

foo foo1
bar bar1

Now, using same shift + alt, place cursors on two different rows. Say after 2 and 3 in below text:

1
2
3
4

Once you paste, the column will be pasted properly.

1
2foo1
3bar1
4
Bharat S
  • 241
  • Can paste a "blob" (previously copied rectangular area) without causing any of the text on the right to shift? – Meryan Mar 25 '23 at 19:35
4

The lines you copied in the column must be exactly the same number as the places you selected to insert. Or the column will be inserted in every place you selected.

Eric
  • 41
  • Life-saver comment, I would never have guessed that! I guess that warrants opening a GitHub issue… or using this plugin: https://marketplace.visualstudio.com/items?itemName=johnguo.columnpaste – lapo Feb 18 '22 at 10:44
0

If I'm understanding Bharat's reply, that's not very useful, is it? That means if I want to compare 2 columns side by side and one column doesn't have as many rows as the other then I can't do it. Or I can do it only if I first count the number of rows in the shorter column so that I can highlight that many rows and then paste into that selection.