Paste a rectangular block in Visual Studio
Solution 1
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.
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.
Solution 2
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.
Solution 3
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.
Related videos on Youtube
Comments
-
serge over 1 year
Is there a way to paste a rectangular block in Visual Studio (2017, for example)?
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:
-
serge almost 7 yearsdid you try it with my example? afraid will not work
-
serge almost 7 yearsGenious ! I didn't know the Shift+Alt combination, only Alt + Selection then Ctrl+V doesn't work !
-
Chris Marisic over 5 yearsSomething that seems to be very important is that you copy the block of vertical text from inside Visual Studio. Any time i used the block of text coming from Notepad++ it would multiplex the text and change my 10 lines into 100 lines.
-
Chris over 4 yearsBroken in 2019 preview. It copies the whole block at each caret.
-
Olivier Jacot-Descombes over 4 years@Chris: See Chris Marisic's comment.
-
Allan Ruin about 4 yearsshift+alt conflict with Windows 10's input method shortcut
-
Tomer Shetah over 3 yearsHello and welcome to SO! Please take the tour and read How to Answer. Please try to add new information over the existing answers.
-
Peter Mortensen over 3 yearsVisual Studio Code is not the same as Visual Studio. The question was about Visual Studio, not Visual Studio Code. In fact, Visual Studio Code is quite broken and crippled wrt. block mode compared to most advanced text editors and IDEs (despite the hype for Visual Studio Code).
-
user24601 about 3 yearsThis does not work at all with VS version 1.5.3.2.
-
Philipp Grathwohl about 3 years@user24601 If you mean VS Code then yes. It has a different method for multiline editing. It works for Visual Studio, though.