{"id":239685,"date":"2022-10-04T08:00:18","date_gmt":"2022-10-04T15:00:18","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=239685"},"modified":"2022-10-04T08:14:15","modified_gmt":"2022-10-04T15:14:15","slug":"comparing-files-in-visual-studio","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/comparing-files-in-visual-studio\/","title":{"rendered":"Comparing files in Visual Studio"},"content":{"rendered":"<p>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\u2019s experiment we\u2019re going to change that.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/diff-view.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-239686\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/diff-view.png\" alt=\"Image diff view\" width=\"989\" height=\"641\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/diff-view.png 989w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/diff-view-300x194.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/diff-view-768x498.png 768w\" sizes=\"(max-width: 989px) 100vw, 989px\" \/><\/a><\/p>\n<p>Various editors and IDEs offer this feature today, but Visual Studio has required the use of extensions such as <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=Heku.VsDiff\">VS Diff<\/a> 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\u2019s time we figured out how to design this feature for Visual Studio.<\/p>\n<p>A <a href=\"https:\/\/developercommunity.visualstudio.com\/t\/is-there-a-way-to-compare-two-files-from-solution\/619706\">feature request<\/a> on the Visual Studio Developer Community is also now gaining steam asking for file comparison, so please <a href=\"https:\/\/developercommunity.visualstudio.com\/t\/is-there-a-way-to-compare-two-files-from-solution\/619706\">vote and comment<\/a> if you agree.<\/p>\n<p>So, with increased interest and multiple viable solutions, what would the right implementation look like for Visual Studio users?<\/p>\n<p>Let\u2019s do an experiment to find out.<\/p>\n<h2>The experiment<\/h2>\n<p>We\u2019re starting out with an extension to kick off the experiment. We call it <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=MadsKristensen.FileDiffer\">File Differ<\/a> and the first iteration adds basic file diffing capabilities.<\/p>\n<h2>Solution Explorer<\/h2>\n<p>Here\u2019s are the commands available from the right-click menu in Solution Explorer:<\/p>\n<ul>\n<li>Compare two files in Solution Explorer<\/li>\n<li>Compare file with another file on disks<\/li>\n<li>Compare file with content of clipboard<\/li>\n<li>Compare file with its unmodified version<\/li>\n<\/ul>\n<h3>Compare selected files<\/h3>\n<p>Select two files in Solution Explorer and right-click to bring up the context menu.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/multi-selection.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-239688\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/multi-selection.png\" alt=\"Image multi selection\" width=\"926\" height=\"411\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/multi-selection.png 926w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/multi-selection-300x133.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/multi-selection-768x341.png 768w\" sizes=\"(max-width: 926px) 100vw, 926px\" \/><\/a><\/p>\n<p>Then select <em>Selected Files<\/em> to see them side-by-side in the diff view.<\/p>\n<h3>Compare with a file on disk<\/h3>\n<p>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.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/single-selection.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-239689\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/single-selection.png\" alt=\"Image single selection\" width=\"932\" height=\"456\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/single-selection.png 932w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/single-selection-300x147.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/single-selection-768x376.png 768w\" sizes=\"(max-width: 932px) 100vw, 932px\" \/><\/a><\/p>\n<h3>Compare with clipboard<\/h3>\n<p>If there is text content on the clipboard, you can compare a file with it by selecting <em>File with<\/em> <em>Clipboard<\/em> from the context menu.<\/p>\n<h2>Code editor<\/h2>\n<p>There are also commands specific to the code editor. By right-clicking inside the code editor, you\u2019ll get the following options for diffing:<\/p>\n<ul>\n<li>Compare selection with clipboard<\/li>\n<li>Compare active file with clipboard<\/li>\n<li>Compare active file with saved version<\/li>\n<li>Compare active file with file on disk<\/li>\n<\/ul>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/editor.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-239687\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/editor.png\" alt=\"Image editor\" width=\"541\" height=\"310\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/editor.png 541w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/10\/editor-300x172.png 300w\" sizes=\"(max-width: 541px) 100vw, 541px\" \/><\/a><\/p>\n<h2>Next steps<\/h2>\n<p>If this feature is interesting to you, please install the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=MadsKristensen.FileDiffer\">File Differ<\/a> extension and take it for a ride. Make sure to share any ideas and bugs on the <a href=\"https:\/\/github.com\/madskristensen\/FileDiffer\/issues\">GitHub issue tracker<\/a>, and feel free to send pull requests too. The <a href=\"https:\/\/developercommunity.visualstudio.com\/t\/is-there-a-way-to-compare-two-files-from-solution\/619706\">feature request ticket<\/a> is a suitable place to share your comments and thoughts, so make sure to vote and comment there as well.<\/p>\n<p>Do you like the idea of community experiments like this one? Let us know in the comments below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":642,"featured_media":239686,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1388,155],"tags":[6861,6862],"class_list":["post-239685","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-extensibility","category-visual-studio","tag-diff","tag-experiment"],"acf":[],"blog_post_summary":"<p>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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/239685","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/642"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=239685"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/239685\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/239686"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=239685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=239685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=239685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}