SheepDev

Text and regular expressions

Find changes in text or configuration files

Tools to use

Scanning a long configuration by eye easily misses changes, while a screen full of additions and deletions can make a small edit look enormous. Finding differences and judging their meaning are separate jobs. Choose the comparison unit first, then focus on the change you need to understand.

Text Diff compares two source strings; it neither executes settings nor decides semantic equivalence. Put the earlier version on the left and the later version on the right, then learn the display with a small example. A consistent direction prevents describing additions as removals.

Why does changing 30 to 60 show two changes?

Before
host=example.invalid
timeout=30
retries=3
After
host=example.invalid
timeout=60
retries=3

Line mode reports timeout=30 removed and timeout=60 added. A single human edit can be represented as removing an old line and inserting a new one. One addition plus one removal does not mean two settings changed: counts describe comparison units, not product requirements or editing actions.

Swapping the inputs reverses additions and removals. Label the earlier version when sharing results. Keeping only the changed fragments can lose context or units, so preserve access to nearby lines and explanations during review.

Inspect a long changed line by character

In character mode, the same example isolates 3 removed and 6 added. Line mode locates the affected line; character mode locates the position within it. For a long URL, CSV row, or a changed number in prose, narrow the area by line before inspecting characters.

More detail is not always clearer. A rewritten paragraph may leave scattered matching characters and many fragments. That is a computed alignment, not a recording of the author's editing history. For substantial rewrites, read the whole paragraph to understand intent.

What disappears when whitespace is ignored?

Compare these as separate inputs: only leading spaces differ
  timeout=30
timeout=30

In line mode, ignoring whitespace can hide differences at the start and end of a line. Compare the two sample lines as separate inputs and toggle the option. It does not simply delete every internal space: hello world and helloworld remain distinct. State what was ignored before reporting that two texts matched.

For whitespace-sensitive formats, a disappearing difference can itself be a warning. YAML indentation, aligned tables, and fixed-width records may change meaning when spaces move. You can temporarily ignore them to reduce noise, but review again with the option off. This filter does not certify correctness.

If every line changed, inspect line endings

Large differences with unchanged wording can come from line-ending conventions or a final newline. A and A followed by a newline are different strings. Editors or paste operations may normalize line endings, so equality in the browser does not prove byte-for-byte equality of the original files.

Do not overwrite the originals with reformatted copies while investigating. Preserve both versions and vary one condition at a time: final newline, indentation, or line order. Changing several at once obscures what removed the difference. Distinguish a cleaner display from evidence that nothing changed.

A moved line can appear as removal and addition

Reordering a list can produce changes even when every line still exists. This tool does not necessarily summarize each relocation as a single move. With repeated text, the chosen alignment can differ from the editing sequence you imagined. Do not reconstruct someone's actions solely from the shape of a diff.

Use list-set operations if the question is membership rather than order, or JSON structural comparison for values independent of object-key order. But order is meaningful in procedures and priority rules. Choose a tool that answers the question instead of sorting first merely to make differences disappear.

Aim for explainable differences, not zero differences

For a review, fix the before/after direction, scan lines, then inspect important lines by character. If you used whitespace filtering, turn it off for a final pass. Being able to say 'timeout changed from 30 to 60; the other values match' is more useful than merely looking at colored fragments.

If no differences appear, check whether the comparison covered enough: omitted lines, another configuration file, or environment variables are invisible unless included. Conversely, a difference is not automatically a defect. Confirm intent and runtime consequences against the specification and appropriate tests.

Formatting and semantic edits can obscure each other

Suppose an entire config is reindented while timeout changes from 30 to 60. Many changed lines can bury the important edit. Compare the originals first, then inspect what the whitespace option removes. This tool does not erase every internal space, so remaining differences may reflect the option's limited scope rather than a failure. Know precisely what the comparison ignores.

A difference disappearing under an ignore option does not make whitespace semantically irrelevant. YAML indentation, string contents and Markdown line breaks may affect behavior. Comparison options change the review lens; they do not certify an edit as safe. Where practical, review formatting changes separately from value changes so the intended modification remains visible.

When sharing a diff, identify before and after and any ignored differences. Reversing the sides reverses additions and removals. 'timeout changed from 30 to 60; indentation was reviewed separately' is more useful than 'one difference.' The aim is to reconcile intent with actual edits, not merely reduce red and green highlights.

Sources

Tools to use

Guides →