tisdag 15 januari 2019

How to compare text files using Visual Studio Code or Notepad++

The need to compare

Sometimes I've had a need to compare two text files against each other, for example

  • to make sure that they were exactly identical
  • or to spot a minor difference among lots of text 
  • or just to make sure that the differences made sense, like when comparing configuration files for test and production environments.
Back in the days when I was using TortoiseSvn, it was as easy as selecting the two files, right click and select "SVN Diff" from the menu, as described here. Nowadays I do something of the following alternatives.

Compare in Visual Studio Code

Suppose you want to compare two files, "First.txt" and "Second.txt". 
  • Open them in VS Code
  • Make sure the explorer in VS Code is expanded
  • In explorer, right click one of the files and select "Select for Compare"
  • Then right click the other file and select "Compare with Selected"
  • See the diff






Compare in Notepad++

To compare files in Notepad++ you need to install a plugin. This was easily done in the plugin manager before, but it is no longer there, so you have to download the plugin and copy it to the Notepad++ plugin folder.
  • Download the compare plugin
    I'm using the 32-bit Notepad++ so I downloaded the x86 version
  • Unzip to
    C:\Program Files (x86)\Notepad++\plugins
  • Start Notepad++, open the "Plugin" menu and look for "Compare"
  • Open the files in Notepad++, select
    Plugins => Compare => Compare
  • To close the comparison, select
    Plugins => Compare => Clear Active Compare




Inga kommentarer:

Skicka en kommentar