Home

Awesome

About

diff-hl-mode highlights uncommitted changes on the left side of the window (area also known as the "gutter"), allows you to jump between and revert them selectively.

In buffers controlled by Git, you can also stage and unstage the changes.

For the usage instructions and the list of commands, see the Commentary section inside the file.

Tested with Git, Mercurial, Bazaar and SVN. May work with other VC backends, too.

The package also contains auxiliary modes:

Usage

Put this into your init script:

(global-diff-hl-mode)

You must also ensure that VC is enabled (e.g. vc-handled-backends is not nil).

Check out the Commentary section in each file for more detailed usage instructions.

Screenshots

diff-hl-mode

Top window: a buffer in this minor mode, bottom window: the corresponding diff.

screenie

diff-hl-dired-mode

screenie

diff-hl-margin-mode

screenie

Requirements

Emacs 25.1+.

Notes

Integration

If you're using some package other than vc to commit changes, it might not run vc-checkin-hook after commits. In that case, you'll need to either add diff-hl-update to the hook it does run, or advise some function that's called in the buffer after its state has changed.

psvn

(advice-add 'svn-status-update-modeline :after #'diff-hl-update)

Magit

If you're using a version before 2.4.0, it defines magit-revert-buffer-hook (or magit-not-reverted-hook), which we use.

When using Magit 2.4 or newer, add this to your init script:

(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)

Tramp

diff-hl should just work with Tramp. But slow or high latency connections can cause performance problems. If you experience such issues, customize diff-hl-disable-on-remote to t. This will change the behavior of both turn-on-diff-hl-mode and global-diff-hl-mode (whichever you prefer to use).