I've changed my diff-mode colours according to this article, but the character-based differences are shown in the original(?) and very bright colours, making them quite unreadable.

How do I change the colours that show the char-by-char differences on the removed/added lines?

2 Answers 2


With diff-refine faces:

(defun update-diff-refine-colors ()
  "update the colors for diff faces"
  (set-face-attribute 'diff-refine-added nil
                      :foreground "white" :background "darkgreen")
  (set-face-attribute 'diff-refine-removed nil
                      :foreground "white" :background "darkred")
  (set-face-attribute 'diff-refine-changed nil
                      :foreground "white" :background "darkblue"))
(eval-after-load "diff-mode"
  • Very good! I merged them into one function. However strangely, earlier all of my diff chunks were automatically refined (char differences showed automatically). Now I have to do it manually. How do I enable it automatically? The linked article suggests a snippet to enable this, but it really did happen on my machine without any such snippet... emacs.stackexchange.com/questions/28271/…
    – forthrin
    Apr 6, 2018 at 13:07
  • I'm pretty sure that Emacs does'nt refine by default. You need to used a function for that.
    – djangoliv
    Apr 6, 2018 at 13:24

There are more faces involved than the ones mentioned in the link you pointed to. The answer is to use C-u C-x = to find out what faces are involved. Those are the ones you need to customize.

Use M-x customize-face to customize the faces you are interested in. If you don't know which faces they are, put the cursor on that highlighted text and use C-u C-x =. Look near the bottom of *Help* for the face name.

From @djangoliv's answer it seems that these are the faces you need to customize: diff-refine-added, diff-refine-removed, diff-refine-changed.

So just M-x customize-face diff-refine-added and define the face as you like.

Do the same for diff-refine-removed and diff-refine-changed.

Easy, persistent, and the way Emacs wants to help you customize faces. See the Emacs manual, node Specific Customization.

  • Ah! That's a brilliant way to find out in the future!
    – forthrin
    Apr 7, 2018 at 5:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.