An easy way to compare a couple of files

In my last blog, I showed an easy way to search for an error message that appears in a group of Syracuse log files using Notepad++ (Link). This time I want to demonstrate an easy way to compare two files using the same tool, Notepad++.  In order to be able to use the compare function, you will need to install a Notepad++ plugin.  I will explain how to do that as well.  Let's take a look at how this works. 

Overview of steps

  1. Install the Compare plugin
  2. Select two files and compare

Install Compare plugin

If you launch Notepad++ and go to Plugins and do not see a Compare option available, you will need to install it. Here are the steps to install the Compare plugin:

  1. From Plugins, go to Plugins Admin..
  2. Click on the Available tab, locate the Compare Plugin and place a checkmark next to it.
  3. Click the Install button and click Yes to the subsequent question.
  4. Upon the restart of Notepad++, go to Plugins, and you should now see the Compare option

    

How to compare two files

  1. Open Notepad++
  2. Press Ctrl+O or from the menu, File Open...
  3. From the Open menu select the first file, in our example, New1.txt, and click Open
  4. Press Ctrl+O or from the menu, File Open... and select New2.txt and click Open
  5. Go to the Plugins menu and select Compare, Compare
  6. Click the triangle up / down button to search up or down the file to show differences. 

    


Compare X3 sample source code files

Now let's do the same thing but using a couple of X3 source code files. But before we do that, I want to talk about a setting that relates the the color coding used by the Compare function.  The Compare function highlights code blocks a certain way and you need to know what the colors mean and where to change them. 

The colors can be changed as desired by going to Plugins, Compare, Settings. Look at the Color Settings section. This section contains your legend for the color codes you will see in the comparison results. You can see an output similar to the below. A little bit later, you will see that there are different colors highlighting blocks of code on each side of the files being compared. 

In my example I changed the "Changed line" setting to a bright yellow. If you make any changes, you can always click the Reset button to go back to defaults.

In the examples that follow, I made a copy of ARCClient.src and named it ZARCClient.src. Then, I made a couple of changes in each file to show a couple of examples of how the compare works.  Open Notepad++ and then I opened the ARCClient.src and the ZARCClient.src file. I added some code into the ZARCClient.src file.

Add Example

Scrolling down to that section, you will notice a code highlighted in green. You will also see several green plus signs next to each of the added lines. At the same place in the ARCClient.src file, you will notice blank space to show you that there is not the same code present. Notepad++ adds the lines to try to keep the code lined up between the two files. 

Remove example

In my example, I also removed a block of code from the ZARCClient.src file. The block of code I removed starts with RAZ [F:TRPT]  and ends with [F:TRPT]VCRNUM = [F:SOH]SOHNUM.  In the compare results, that code block is highlighted in red with red minus signs on the ARCClient.src side and blank on the ZARCClient.src side.

Move example

In another example, I moved a block of code that begins with "Issue 110704" in the ZARCClient.src file.  The compare shows this code block highlighted in blue and has double ended arrows next to the code block. There will be a matching code block highlighted in blue on the ARCClient.src.  During my testing, I did move another code block in the ZARCClient.src file. I noticed that while the compare function found both occurrences of the code that was moved, Notepad++ is not good at matching up the different code blocks somehow.  Just something to keep in mind

.

Just a last couple of things

There are a couple more features I wanted to mention. They may assist you in locating changes a little quicker, especially if you files you are comparing are lengthy. They are the Document map and Navigation Bar options. 

The Document Map button (see below) will display on the right side of the screen, a big picture (but in tiny print) of both files.  It could serve to help you locate the areas you are comparing more quickly. 

The Navigation Bar button will display its result on the right side of the screen. The Compare NavBar shows the areas the comparison has highlighted. As you can see, all the other code/text has been removed. So, you only see highlighted color bands.  This could also be helpful in locating changed/new/deleted code.  For both the Document Map and Navigation Bar buttons, you can click in those areas and scrollbars for the ZARCClient.src and ARCClient.src will be moved to that respective area. 

These are a few tips and trips when using Notepad++ to compare a couple of files.  I hope this information helps get you up and running faster and helps save you time when you compare files. 

Anonymous