Compare 2 files side by side in a Text editor

Being a developer, I have a habit of changing the source code of a single file. It's a tough task to find out what has been changed as we cannot go and compare each line. What if we could compare 2 files side by side with the only difference highlighted?



Most of the IDM like Visual studio and Eclipse do have functionality to compare the original and changed code, but to keep it simple - we will use the Notepad ++. Notepad++ is one my favorite text/Source code editor and I personally prefer it over sublime.

Compare 2 code files in Notepad++

Like chrome or mozilla add-ons, Notepad supports plugins which needs to be downloaded. The first thing you should check if you already have the compare plugin. You can try to have a look inside Notepad++ >> Plugins >> Compare.

If you don't find it, there are 2 ways to get the plugin.

1. Direct download

  1. Download the zip from sourceforge 
  2. Unzip the ComparePlugin.dll and copy and paste inside the C:\Program Files\Notepad++\plugins
  3. Re-open the Notepad ++

2. Plugin manager

  1. Open Notepad ++ and go to Plugins >> Plugin manager >> Show plugin manager
  2. The list of all available plugins will be displayed.
  3. Find and check the Compare plugin and click on install.

How to compare the files

Let's assume that you want to compare file1.txt with file2.txt  and proceed.
  • Close all the files open in different tabs.
  • Now, open both the files (2 files which you wish to compare)
  • Go to Plugins >> Compare >>Compare
Compare 2 files side by side

In the above picture, you can see that Line 6 has some difference and it has been highlighted. In a second document (Line 14) has a new line which has been shown with green highlight.

If you could notice a panel on the right hand, which has some highlights. Those highlights are the difference between 2 documents. If you have a big text file with a thousand lines of code, just click on the  highlight to jump on the particular line.
About author

Written by Sangram Nandkhile, A software developer and a part time blogger. You can follow him on the Facebook and twitter web or sign up for the email newsletter for your daily dose of how-to guides and video tutorials.

No comments :

Post a Comment