Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comparing the contents of two files in Sublime Text

I have two cloned repositories of two very similar open-source projects, which I have been working on in different instances in Sublime Text 2 to arrive at my desired result. Code from both of these projects was used. I have been using Git as version control for my project, but have not included the original projects. Thus, I would like to be able to quickly compare the contents of two files of the original project and compare the differences between them and my project.

I was hoping that Sublime Text 2 would have a "Compare File" feature, but I can't seem to find anything related to it in the settings or online. A third-party ST2 package to accomplish this task would also work well. Is such a task possible to do within the ST2 text editor?

like image 758
LanceLafontaine Avatar asked Sep 16 '14 16:09

LanceLafontaine


People also ask

Can I compare two files in Sublime Text?

Open both the files in Sublime Text, Now Open Command Palatte again and type Compare with, Now both the files will be compared side-by-side and displayed in a new window.

How can I compare the contents of two files?

Use the diff command to compare text files. It can compare single files or the contents of directories. When the diff command is run on regular files, and when it compares text files in different directories, the diff command tells which lines must be changed in the files so that they match.

How do you compare two files to see if they are the same?

Probably the easiest way to compare two files is to use the diff command. The output will show you the differences between the two files. The < and > signs indicate whether the extra lines are in the first (<) or second (>) file provided as arguments. In this example, the extra lines are in backup.


1 Answers

You can actually compare files natively right in Sublime Text.

  1. Navigate to the folder containing them through Open Folder... or in a project
  2. Select the two files (ie, by holding Ctrl on Windows or on macOS) you want to compare in the sidebar
  3. Right click and select the Diff files... option.

like image 95
Derek 朕會功夫 Avatar answered Sep 24 '22 06:09

Derek 朕會功夫