Emacs: highlight changes

jplindstrom on 2005-01-16T18:10:47

The colleague who is my Emacs mentor found one very cool and potentially very useful feature yesterday: Highlight Changes. Instant color-coded diff of the changes you made since opening the file.

Put this in your .emacs file:

;; Hightlight Changes

; Turn it on for all opened files (global-highlight-changes "passive")

; Toggle display Highlights (global-set-key (kbd "\C-x \C-h h") 'highlight-changes-mode) ; Highlight toggle (global-set-key (kbd "\C-x \C-h r") 'highlight-changes-remove-highlight) ; Remove colors in region (global-set-key (kbd "\C-x \C-h c") 'highlight-changes-rotate-faces) ; rotate Colors

(global-set-key (kbd "\C-x \C-h \C-n") 'highlight-changes-next-change) ; Next change (global-set-key (kbd "\C-x \C-h \C-p") 'highlight-changes-previous-change) ; Previous change


and it will start tracking changes. It won't highlight the changes right away, that would just be annoying. But when you are curious about all the possible ways you screwed up the text, hit
C-h C-h h
and the changes gets highlighted. Or you can jump back and forth between the changed portions.

Yummy!