Visual Studio allows to edit multiple lines at the same time. This is very useful to apply the same change to multiple lines. For instance when you want to add the modifier to multiple properties.
Press Alt while selecting the block with the mouse:
Press Alt+Shift+Arrow to select the block to edit:
If you want to edit multiple places that are unaligned, you can use the multi-cursor edit. Press Ctrl+Alt and click where you want to add a caret. The
You can insert a caret at all places where the current word exists. Select the word you want to match and press Alt+Shift+;. Visual Studio will select all the locations that match the selected text in the current document.
You can select just the next matching location by using Alt+Shift+.
This post is part of the series 'Visual Studio Tips and Tricks'. Be sure to check out the rest of the blog posts of the series!
- View and edit the Tab Order of Windows Forms Controls
- Comparing files using Visual Studio
- Visual Studio Tips and tricks: Clipboard history
- Visual Studio Tips and tricks: Open recently closed files
- Visual Studio Tips and tricks: Multi-line and multi-cursor editing (this post)
- Visual Studio Tips and tricks: Extend/Reduce selection
- Visual Studio Tips and tricks: Undock/Re-dock a tool window