Compare Text Files and Tabs in Sublime Text

How to diff two files or tabs in Sublime Text: built-in Diff Files, incremental diff markers, plugins, and what to check before trusting the result.

Sublime Text can show differences between two versions of a text without changing either one. It includes a basic comparison feature, change markers for the file you are editing, and plugins that add side-by-side views. Which one fits depends on whether your text is saved to disk, whether you need a line-level summary or word-level detail, and where the comparison result needs to go afterward. This guide covers what each approach does and how to choose. No hands-on test results were supplied for this article, so feature descriptions reflect commonly documented behavior. Menu labels and availability vary between Sublime Text 2, 3 and 4, so check them in your own build.

What a diff actually changes

A diff is read-only. It compares two texts and reports which lines were added, removed or kept. Neither source file is modified unless you deliberately apply or revert a change. The output describes the differences and does not replace either version.

Most diff tools compare line by line. This matters for prose. If each paragraph is stored as one long unwrapped line, changing a single word marks the whole paragraph as removed and re-added. For paragraph revisions, you get a more useful result if the text is wrapped at sentence or clause boundaries before comparing, or if the tool highlights changes within a line. Wrapping the text first changes the stored line breaks. Do it on copies if the original formatting matters.

Diffs compare stored characters, not appearance. Two lines that look identical can still be reported as different. Two lines that look different on screen because of font or rendering can still match. The section on hidden characters below explains why.

Ways to compare text in Sublime Text

Built-in Diff Files for two saved files

In Sublime Text 3 and 4, you can open a folder or project and select two files in the sidebar (Ctrl-click, or Cmd-click on macOS). Right-click and choose Diff Files. The result opens in a new tab as a unified diff: removed lines start with a minus sign, added lines start with a plus sign, and unchanged context lines have no prefix. Both files must be visible in the sidebar, so they need to be saved on disk. If you use Sublime Text 2, check whether your build has this menu entry. If it doesn't, use one of the plugin options below.

--- draft-v1.txt
+++ draft-v2.txt
@@ -1,3 +1,3 @@
 The committee reviewed the proposal
-on Tuesday and approved it.
+on Tuesday and approved it with changes.
 Implementation begins next quarter.

The snippet above is an illustrative example of the unified format, not output captured from a test. It also shows the line-level limitation: three words were added, but the whole second line is reported as replaced.

Incremental diff markers for the current file

Since version 3.2, Sublime Text can mark modified, added and deleted lines in the gutter of the file you are editing. It compares the buffer against the saved file or, inside a Git repository, against the committed version. This behavior is controlled by the mini_diff setting. The editor also provides commands to jump between modifications, show the original text inline and revert individual changes. This answers the question "what have I changed in this file?" It does not compare two unrelated files or tabs.

Comparing two tabs, unsaved text or the clipboard

The sidebar method needs saved files. To compare two unsaved tabs, a pasted draft or the clipboard, you have two options: save each version to a temporary file and use Diff Files, or install a plugin. Community packages distributed through Package Control have offered this. For example, FileDiffs is commonly described as diffing the current tab against another tab, the clipboard or a selection, and Sublimerge as providing a side-by-side, highlighted comparison view. Packages change ownership, pricing and compatibility over time. Before relying on one, read its current listing and confirm it supports your Sublime Text version.

Side-by-side view

The built-in Diff Files output is a single unified listing, not two panes with synchronized scrolling. If you want two aligned columns with highlighted changes, you need a plugin or an external diff tool. You can also approximate the layout by opening each file in a split layout (View > Layout), but that only arranges the files. It does not compute or highlight differences.

Which approach suits your task

Approach | Compares | Needs saved files | Output | Best for
Diff Files (sidebar) | Two files | Yes | Unified text diff in a new tab | Quick check of two drafts already on disk
Incremental diff markers | Current buffer vs saved or committed version | Current file only | Gutter marks, inline original, per-change revert | Reviewing your own edits before saving or committing
Tab/clipboard plugin | Tabs, selections, clipboard | No | Usually unified diff | Comparing pasted or unsaved text
Side-by-side plugin or external tool | Two files or buffers | Depends on tool | Two highlighted panes, sometimes word-level | Long paragraph revisions where line-level output is too coarse

If both versions are already saved, start with Diff Files: it needs no extra software, and its output is plain text you can copy anywhere. If you only want to see what you changed in one file, the gutter markers are faster. Use a plugin when the text is unsaved or you need side-by-side or within-line highlighting. The tradeoff is an extra dependency to install and maintain.

Will the result stay readable and usable?

Copying and sharing diff output

Unified diff output is plain text. When you copy it into an email, ticket or chat, the plus and minus markers come along. Color highlighting is part of the editor's display, so it is lost. Side-by-side views from plugins usually don't copy as a matching plain-text layout. If someone else needs to read the comparison, share the unified text or a patch file instead of describing the colored view.

Accessibility

The text markers in unified output are characters that a screen reader can announce. Side-by-side views and gutter markers often show changes mainly through color or icons. That can be hard to perceive with low vision, color-vision differences or assistive technology. How well a particular plugin works with a screen reader depends on the plugin and the operating system. No test results were supplied here, so check this with your own setup if it matters.

Hidden differences that look identical

Because a diff compares stored characters, it can flag lines that look the same. The usual causes:

  • Line endings: one file uses Windows CRLF and the other Unix LF, so many or all lines can differ. Check View > Line Endings in each file.
  • Trailing spaces or tabs vs spaces: invisible in normal view. Turning on whitespace rendering (the draw_white_space setting) helps.
  • Unicode normalization: an accented letter can be stored as one precomposed character or as a base letter plus a combining mark. Both look the same but are different characters.
  • Lookalike characters: Latin letters swapped for Cyrillic or Greek lookalikes, or text restyled with Unicode "font generator" characters, is a different character sequence from the plain text it imitates.
  • Zero-width and bidirectional control characters: these can be invisible or can reorder how text displays, so a line may look unchanged or reversed while its stored order is different.

If a flagged line looks unchanged, check the characters themselves, not just how they render. Normalize line endings and encoding in both copies before comparing, and keep the originals unchanged.

Sensitive text and online diff services

Everything described above runs locally in Sublime Text. Pasting confidential drafts, contracts or code into a web-based diff tool sends that text to a third party, where it may be logged or stored. For sensitive material, use the built-in comparison or a local plugin. Before installing a plugin, check that it doesn't send content anywhere.

Gaps in this guide

No tested output, version-specific screenshots or current plugin listings were available for this article. Exact menu names, Sublime Text 2 support, plugin pricing and plugin compatibility with recent builds should be confirmed in your installed version and on each package's current page.