Comparing files in Visual Studio
As developers, we often need to compare two files to find the differences. Sometimes, even comparing the content of the clipboard with a file on disk. And again, sometimes comparing our local changes to previous versions from our Git commit history. There is no straightforward way in Visual Studio to do those things today, but in this month’s experiment we’re going to change that.
Various editors and IDEs offer this feature today, but Visual Studio has required the use of extensions such as VS Diff to provide the feature. An interesting thing about the various implementations is that they offer slightly different features and with different UI paradigms. They all perform basic comparison between files rather well, and we think it’s time we figured out how to design this feature for Visual Studio.
So, with increased interest and multiple viable solutions, what would the right implementation look like for Visual Studio users?
Let’s do an experiment to find out.
We’re starting out with an extension to kick off the experiment. We call it File Differ and the first iteration adds basic file diffing capabilities.
Here’s are the commands available from the right-click menu in Solution Explorer:
- Compare two files in Solution Explorer
- Compare file with another file on disks
- Compare file with content of clipboard
- Compare file with its unmodified version
Compare selected files
Select two files in Solution Explorer and right-click to bring up the context menu.
Then select Selected Files to see them side-by-side in the diff view.
Compare with a file on disk
If you only selected a single file, a file selector prompt will show up to let you select which file on disk to diff against.
Compare with clipboard
If there is text content on the clipboard, you can compare a file with it by selecting File with Clipboard from the context menu.
There are also commands specific to the code editor. By right-clicking inside the code editor, you’ll get the following options for diffing:
- Compare selection with clipboard
- Compare active file with clipboard
- Compare active file with saved version
- Compare active file with file on disk
If this feature is interesting to you, please install the File Differ extension and take it for a ride. Make sure to share any ideas and bugs on the GitHub issue tracker, and feel free to send pull requests too. The feature request ticket is a suitable place to share your comments and thoughts, so make sure to vote and comment there as well.
Do you like the idea of community experiments like this one? Let us know in the comments below.