7

I have already read Comparing the contents of two files in Sublime Text but the answers (either the native "Folders > Diff files" feature, or using FileDiffs) show the differences between 2 files like with the diff tool, which I don't want:

 --- file1.py
 +++ file2.py
 @@ -1,21 +1,19 @@
 -import os
 +import os, sys
 import numpy as np
 -print('hello')
 +print('hello world')
 -import sys

Instead, I would like a side-by-side comparison like this with PSPad native diff tool:

enter image description here

How to achieve this side-by-side comparison between two opened files in Sublime Text (2 or 3)?

Is it possible natively with Sublime Text?

Basj
  • 41,386
  • 99
  • 383
  • 673
  • The only side-by-side diff package I've ever used for Sublime is [Sublimerge 3](https://packagecontrol.io/packages/Sublimerge%203) (not to be confused with Sublime Merge). There is also [Sublimerge Pro](https://packagecontrol.io/packages/Sublimerge%20Pro) for ST2. They're commercial packages, though there is a free trial. There may also be some other package that does a side by side diff, though I don't recall one at the point where I bought this one. – OdatNurd Jun 29 '21 at 22:09
  • @OdatNurd Oh there is Sublimerge *and* Sublime Merge? I thought they were the same thing! The latter is a git client, right? Maybe it also does side-by-side comparison with colors, is that correct? – Basj Jun 30 '21 at 09:26
  • `Sublime Merge` is a `git` client, yes; It does side by side diffs, but only for things in source control (you can use it as a merge tool standalone with some setup, but that gets you a merge pane you can't turn off). `Sublimerge 3` and `Sublimerge Pro` are packages for Sublime Text that provide side by side diff/merge functionality and can be integrated with source control if desired. – OdatNurd Jun 30 '21 at 18:49

2 Answers2

7

Installation for Windows and Linux:

  • Press CTRL + SHIFT + P
  • Type Package Control: Install Package
  • Press ENTER
  • Type Compare Side
  • Select package named Compare Side-By-Side

How to use?

  • Select one tab which you want to compare
  • Right Mouse Button on second tab which you want to compare
  • Select Compare with active tab

How it looks?

Compare Side-By-Side example

ToTamire
  • 1,425
  • 1
  • 13
  • 23
3

Yes, you can do this without plugins. First, select View → Layout → Columns: 2

View -> Layout -> Columns: 2 screenshot

making your window look like this

2 columns screenshot

Then, drag your desired tab over to the other pane

2 panes, 2 files screenshot

and you should be all set.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • 1
    This is already interesting indeed, but it would be great to have the modified lines highlighted / have a coloured background (see my original post PSPad screenshot). – Basj Jun 29 '21 at 19:19
  • Sublime Text 4 features markers on the left gutter indicating lines added, changed, and deleted, assuming your color scheme supports them. It doesn't show the diff live, but like OdatNurd mentioned, there may be other resources you can try. – MattDMo Jun 30 '21 at 15:49
  • Here is an image https://i.stack.imgur.com/wweCO.png – MattDMo Jun 30 '21 at 15:56
  • This is interesting @MattDMo, maybe you can edit your answer to include this screenshot, useful for future reference. – Basj Jun 30 '21 at 20:49