Here is one I just discovered just last week by accident. When you are doing a diff on a file to compare what has changed from the source control, the diff window can be used to edit the file directly. (works on both Git and TFS source control)
I always assumed the window was just a read only view, but on a whim I tried it and it works. This is nice because, in my workflow, I typically do a diff of my files before I check them in to ensure that I don’t have any unwanted edits still hanging around. But without this, I would have to do a diff, take a note of where the unwanted change is, go open the original file and make the edits, then do a new diff on the file again (rinse and repeat).
For example, look at the following diff view. You can see that I added a lot of code to this file, but maybe during the process I added the namespace “Windows.UI.Xaml.Shapes” which is no longer needed now that I’ve finished the full edit.
Traditionally I would have opened GamePage.cs, removed that line, saved it and then done a new Diff on the file. But because this Diff view is live on the file, I can just remove that line in the right hand pane and the Diff updates in real time. In the picture below, note that the green bar (indicating a new line inserted) is now gone from the red circle area.
This is also a great way to find and eliminate all that commented out code that people sprinkle around as they make changes but you don’t want to check it in.
(Of course always rebuild and test after you do this before you hit the commit button )
This post is part of a series of Visual Studio tips. The first post in the series contains the whole list.