How to Compare files in Visual Studio Code ?

How to Compare files in Visual Studio Code ?

Visual Studio Code, supports File Compare of Working Files and let you compare the changes in different modes.  You can leverage this feature either from File Explorer Side Bar  or by using “Files:Compare Opened File With” command. VS Code Compare tool works in a very similar way like other compare tool and you can change the setting to view the changes in “In Line Mode” or “Merged Mode” within the code compare window.

Consider you made some changes in local settings file which is specific to the current folder / project and wants to compare with global settings.  When you have both the files in “Working Files” sections, Select any of the file, and choose “Select for Compare” from the context menu.

image

Select the other file to which you want to compare. Now in the context menu, “Compare with <Previously Selected File for Compare>” would appear . ( In this case “settings.json”)

image

Select “Compare with ‘settings.json’” options, you should be able to view a side by side compare window with color highlighting on the changes as shown in image below.

image
Compare windows will appear in a side by side view by default. You can change it to “Inline View” by selecting “Switch to Inline View” options.

Visual Studio Code Tip : How to navigate through history of files in Visual Studio Code ?

image

Following image shows how an inline compare view looks.

image

If there are multiple changes, you can use the “Preview” and “Next” change arrow to navigate through the changes.

Related Read : A Quick Lap Around Visual Studio Code

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.

3 Comments to “How to Compare files in Visual Studio Code ?”

Comments are closed.