kunal-chowdhury.com

Visual Studio Productivity Tips: Adding and deleting text at multiple caret positions


The latest version of Visual Studio 2017 (version 15.8) supports multiple carets. This means that, you can now create multiple insertion and selection points in your code file which will improve your productivity in certain conditions.

 

In this part of my Visual Studio Productivity Tips series, we will discuss how easy it is to add or delete code at multiple cursor positions.


Visual Studio Productivity Tips:


 

 

The latest version of Visual Studio 2017 adds the ability to insert selection points to multiple places of your code file, so that, you can start typing the same code in all those caret positions.

 

In the previous versions, the support was limited to a vertical selection. That means, you were able to select a vertical line or rectangular area by pressing [ Shift + Alt + Click ] OR [ Shift + Alt + Arrow keys ]. With the Visual Studio 2017 (version 15.8 and above), this functionality has been extended to random caret positions. This can be of three types:

 

  1. Add additional carets to your document:
    As shown in the video, you can now use [ Ctrl + Alt + Click ] to add the additional carets to your document. Then you will be allowed to add or delete text in multiple places at the same time:

  2. Add additional selection that matches your current selection:
    You are also allowed to select the next matching selection in a document. When a selection is already there, press [ Shift + Alt + . (dot) ] to add the next matching selections one by one. This helps you to verify the context of each additional selection.

    If you would like to skip over a match, you can press [ Ctrl + Alt + Shift + . (dot) ] to move the last matching selection to the next instance.

  3. Add all matching selections in a document:
    When you like to select all matching selections in a document, this trick is helpful. You can press [ Ctrl + Alt + Shift + , (comma) ] to grab all matching selections in a document, so that, you can replace all of them at a single shot. It's almost like the "Find and Replace" functionality. Checkout how it works:

Visual Studio Productivity Tips: Adding and deleting text at multiple caret positions

 

Liked the post? Don't forget to share it with your friends and colleagues. This will help them to complete their job smoothly and efficiently. Also, don't forget to read out my other posts on Visual Studio Productivity Tips. Who knows those could be beneficial too.

 

 


Kunal Chowdhury
If you have come this far, it means that you liked what you are reading (Visual Studio Productivity Tips: Adding and deleting text at multiple caret positions).

Why not reach little more and connect with me directly on Twitter, Facebook, Google+ and LinkedIn. I would love to hear your thoughts and opinions.

Authored Books: