serge
serge

Reputation: 15239

Paste a rectangular block in Visual Studio

Is there a way to paste a rectangular block in Visual Studio (2017, for example)?

Enter image description here

The only way I can do it now is paste first the values, and then "surround" the values column with from left and right, like this:

Enter image description here

Upvotes: 29

Views: 23025

Answers (3)

Philipp Grathwohl
Philipp Grathwohl

Reputation: 2836

If I understand your question correctly, you can hold Shift + Alt to select a block with the keyboard.

Copy the block from within Visual Studio and then use Shift + Alt again to select the column you want to paste it to. You can then paste it. The same as you would in Notepad++.

If you want to use the mouse you only need to hold the Alt key.

Copy multiline block in Visual Studio

Update for VS Code

In VS Code it seems to require the mouse. Click to the beginning of what you want to copy, press and hold Shift+Alt then click to the end of what you want to copy. Then release the keys and copy. When pasting, do the same for the column you want to insert.

Copy multiline block VS Code

Update: Works well and flexible in VS Code for Mac too

  • Copy block and paste at multi line cursor of same line height as the block — else it fails!
  • Very flexible! Pasted lines can have uniform or character length (=column width)
  • Optionally: Very easily enter a separator string while still in multi cursor mode.

Merge lines by copying block and pasting at multi line cursor of same line height - Visual Studio Code 1.72.2 on macOS 11.7 Visual Studio Code 1.72.2 on macOS 11.7

Upvotes: 44

uri
uri

Reputation: 31

The pasted area has to have the same rows as the copied area. Not in Notepad++, yes in Visual Studio Code.

In the last one, you must look at the IDE's bottom.

Upvotes: 2

Amit Kumar Singh
Amit Kumar Singh

Reputation: 4475

Use the Left Alt key on the keyboard + mouse to select multiple lines. Then, select the paste region in the same manner. And press Ctrl + V.

Upvotes: 1

Related Questions