Skip to content
Theme:

Difftastic — my new favourite diff viewer

I abandoned graphical code editors years ago. Something that GUI IDEs like Visual Studio Code do really well is the diff preview. This is something I missed a little at the beginning, but since I started using Delta, I never missed the GUI again.

I don’t remember how that happened, but over the years I also abandoned Delta, and I trained my eye to be good at scanning the default git diff output. Occasionally I still miss side-by-side view though. Recently my good friend Oliver recommended Difftastic to me. It works fundamentally different than Delta, and can be used as an individual diff tool to compare files/folders or as a git diff pager. Let’s look at the example.

Preview of two almost identical files
package main

import "errors"

var ErrValidation = errors.New("too short")

func validate(s string) error {
	if len(s) < 3 {
		return ErrValidation
	}

	return nil
}
package main

import "errors"

var ErrValidation = errors.New("too short")

func validate(s string) error {
	if len(s) < 4 {

		return ErrValidation

	}
	return nil
}

The only meaningful difference that is actually interesting is the value change (3 vs 4). There are some spacing differences between the two files that I deliberately added to better illustrate how it handles noise. Now look at the output of the default git diff and difft.

Preview of two almost identical files in git diff Preview of two almost identical files in Difftastic

Difftastic gives a super minimalistic result that doesn’t clutter the output with noise like white spaces or added removed lines. It respects my terminal theme, and very nicely integrates with git diff and my beloved LazyGit. This is a little addition to my setup, but I like it a ton!

Leave a comment

👆 you can use Markdown here

Your comment is awaiting moderation. Thanks!