VS Code has a very powerful diff tool. This quick post is going to teach you how to perform diffs (compare files) in VS Code.
There's two primary types of diffs you can do with VS Code.
- The command line ‘diff’ tool offers a great choice for users comfortable with the Terminal. Diff allows you to easily compare two files, with the command output reporting back any differences between the inputted files.
- Compare any text sources. Apart from comparing files' or folders' contents, you can open an empty Differences Viewer and paste any text or drag files into the right and left panels to compare. This can be useful, for example, if you want to compare an application's console output with the output of the same application albeit a little modified.
- Araxis Merge is a three-way document comparison, merging, and folder synchronization tool. It can be used to compare source code, web pages, XML, and other text files, as well as Word and Excel documents, PDFs, and RTF files. It’s available for both Windows and Mac OS X for $129 for the Standard version and $269 for the Professional version.
- Compare two files in your project
- Compare git file versions
Compares two files and shows the diff. Getting Started. Install the module with: apm install compare-files. Click on the two files that are to be compared in the tree view; Invoke the command using any of the below: From Command Palette (⌘+⌂+P) invoke Compare Files: Compare; Right click on one of the selected files and choose Compare.
Diff from Explorer Panel
This is the quickest, easiest way to bring up the diff panels.
1. Right click the first file and 'Select for Compare'
2. Right click on the second file and 'Compare with Selected'
3. You should see the diff panel appear once you've completed these steps:
Note: you can also CTRL-select both files, right click on one, and select 'Compare Selected' to achieve the same thing:
Diff from command line
This is convenient if you want to build up muscle memory of typing out the commands into the terminal. Here's how to do it.
Paste this command into the command line with your file names.
Compare Two Files On Mac
Executing this command should bring up the diff panel, just like it did from the explorer window.
Git diff in from the Activity Bar
If you would like to compare your local file changes with the latest git version of a file, click the git icon in the activity bar, then select the file that you would like to compare.
Note: you can also edit files from within the diff panels! VS Code is awesome.
I hope this helped you! Diffing in VS Code is very useful for quickly seeing changes between two files. It also helps to remind yourself of the changes you've made from the master version of a file on git once in a while. VSCode diffs are a great thing to add to your developer toolbox.
If you’ve ever needed to compare two text files you’ll know it can be tedious – but what you may not know is Notepad++ can do this, and do it quite well.
If you’re not already familiar with Notepad++, it is a text editor designed for coding. This small piece of software has big features, such as allowing you to view code with colour styling and line numbers to make the code easier to read and debug.
How to compare two text files using Notepad++
These instructions have been written for Notepad++ v7.8.2.
Step 1: Install Compare plugin
- Open Notepad++
- Click on the ‘Plugins’ then ‘Plugins Admin’
- A list of available plugins will appear
- TIP: if the list is empty you need to check your Internet connection or proxy settings.
- Either search or scroll until you see ‘Compare’
- Place a tick next to the name then click on the ‘Install’ button
- Once the plugin is installed you will be prompted to restart Notepad++
- Click ‘Yes’ to finish the install.
Mac Compare Text Files
Step 2: Compare two files using Notepad++ Compare plugin
- Now that the Compare plugin has been installed, open two files
- Click on the ‘Plugins’ menu then ‘Compare’ and ‘Compare’ again
- The files will be displayed, side by side, with the differences highlighted
Compare 2 Text Files Mac
Please note: it helps to keep the ‘old’ copy of your file on the left and the ‘new’ on the right – this should help with understanding how the plugin shows the difference between files.