Comparing code in different files is a common need for developers, yet it often disrupts the flow of your work. We’ve heard your feedback and are excited to introduce a new compare feature in Visual Studio. This feature enables you to compare code files directly within the Solution Explorer, eliminating the need for external tools and keeping you in your developer flow.
Effortless Code Comparison with Two Options
Recognizing that developers have different scenarios for comparing files, we’ve introduced two convenient ways to achieve the same goal: effortless code comparison to understand differences.
1. Compare Selected Context Menu
We’re introducing the “Compare Selected” context menu option, designed to simplify multi-file comparison. Hold down the Ctrl key and select two files in the Solution Explorer that you want to compare. After selecting the files, right-click and choose “Compare Selected” from the context menu. Visual Studio will instantly display a side-by-side comparison view, highlighting differences between the chosen files.
2. Compare with… Context Menu
Our second option, the “Compare with…” context menu, provides a straightforward method to compare a file in your solution with an external file on your disk. Right-click on the file you wish to compare within the Solution Explorer, then select “Compare With…”. This action opens a File Explorer window, enabling you to navigate to any file on your disk and initiate the comparison process.
Let us know what you think!
We’re interested in learning about your experiences with the new compare feature and how it’s influencing your development workflow. If you have suggestions, comments, or insights, please don’t hesitate to share them with us at this link.
What version did the “compare files” become available?
Compare files became generally available in Visual Studio 17.7
1. Is it possible to integrate a feature that allows comparing two clipboard files, with one pasted into the left panel and the other into the right panel?
2. Could you please implement command-line functionality for this ability?
Compare two files: devenv.exe /diff /left:file1 /right:file2
Compare blank (will paste from clipboard) and file: devenv.exe /diff /right:file2
Compare two blanks: devenv.exe /diff
I mean left panel also should be editable!
Re. 2: Command-line functionality for comparing two existing files already exists since (at least) VS 2015 (vsDiffMerge.exe), see, for example, https://stackoverflow.com/q/32948698/87698 for details.
I have the Comparer “Beyond Compare”, also used in Git, how to configure it?
Marcus
We evaluated this feature, and we discovered that we seldom need to compare source code files contained in the Visual Studio solution, but that we often need to compare data files which are located outside the solution directory. Currently, there seems to be no way to do that with Visual Studio, since "Compare with..." is only available for files shown in Solution Explorer.
Thus, our suggestion would be to add a "Compare with..." context menu entry...
Would be nice if I could compare files across projects in the solution…
We plan on adding the ability to compare files across projects in the next release.
There's one place that's sorely missing a file comparison option, and that's the dialog box that comes up after a VS crash, where it offers to recover from a set of backup files vs keep what's in your local source...and you have no idea whether the content of the backup folder is the latest or not. So I always end up using an external tool to compare each file manually and (possibly) do some...
Alright. This is a useful and well-integrated feature.
just a small translation shell of the French contextual menu: “Comparer la sélection” ou “Comparer les fichiers sélectionnés” and not “Comper sélectionné”.
Thank you for your work.
As an active reader, I wana say, I can understand that you seem proud of the work you have done, though still I would like to raise the question do we really need multiple posts talking about this feature?
4th October 2022: https://devblogs.microsoft.com/visualstudio/comparing-files-in-visual-studio/
17th May 2023: https://devblogs.microsoft.com/visualstudio/visual-studio-2022-17-7-preview-1-is-here/
13th June 2023: https://devblogs.microsoft.com/visualstudio/visual-studio-2022-17-7-preview-2-is-here/
8th August 2023: https://devblogs.microsoft.com/visualstudio/visual-studio-2022-17-7-now-available/
10th August 2023: https://devblogs.microsoft.com/visualstudio/lets-co-create-your-voice-matters/
15th August 2023: https://devblogs.microsoft.com/visualstudio/my-favorite-features-in-visual-studio-17-7/
21th August 2023: https://devblogs.microsoft.com/visualstudio/new-in-visual-studio-compare-files-with-solution-explorer/
4 blog posts alone in August.
I think we do need multiple posts; repetition allows newcomers and people not following this blog very often to be aware of any new features Visual Studio has added. This helps with discoverability, so it’s welcome 🤗
Tuition is always a matter of repetition, and you have to inform newcomers.
I just found out today how to use the compare feature!
Thanks to its shortness and its well done screen shots, this is the first blog post about this feature where my diagonal reading suffices to get me to use the feature.
Thanks for the feedback! We’ll try to minimize duplication in the future.
would be nice to be able to compare selected text with clipboard