How to select and edit multiple lines at once in Visual Studio

In Visual Studio to edit multiple lines which are vertically aligned at once press Alt and select the aligned block and then just start typing as in example 1 below. This approach overwrites the selected block.

If you want to select multiple lines / edit multiple lines in non aligned blocks you need to press Ctrl+Alt and explicitly click where you want each cursor to be and then just start typing as in example 2 below. With this approach you only add new code not overwrite existing code.

Don’t forget about the Delete button if you want to quickly remove snippets/blocks rather than add/amend them.

Editing multiple lines at once in Visual Studio

Leave a Reply

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