.NET Power Tip 18: Visual Studio Block Selection / Block Copy Mode

Posted by

Usually, when selecting text in a text editor, the text is selected line by line. This means that if I would hold the mouse button in the middle of a line and drag down, the selection would automatically select the current line to the end and continue with the next line.

With block selection it is possible to select a rectangular block of text. Just hold down the ALT key while making a selection:

Abb7_BlockSelection

This can be very convenient, if you need to delete text in multiple lines, for example.

It is even possible to replace the entire block of text with something else. You can select a block using the ALT key, hit CTRL-V, select another block holding the ALT key and use CTRL-V to paste from the clipboard.

It is even possible to select an empty block, that is a code block that has a width of zero characters. Note the thin blue line after “Tasks”:

image

Suppose we would like to change the word “Tasks” to “TasksList”. With the block selected, we can just type the characters and they will be inserted on every line:

image

image

image

image

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.