Weekly Emacs tip #6: highlight uncommitted changes: diff-hl
After enabling diff-hl-mode
by Github user dgutov
any lines with uncommitted changes in a (version controlled) file will be highlighted in the margin. In large files, for example, this makes it easy to spot the sections that you have edited.
Here is how I enable diff-hl-mode
for all files:
;;;;;;;;;;;;;;;;;;;; ;; Enable diff-hl-mode (https://github.com/dgutov/diff-hl) to ;; highlight lines with uncommitted changes (use-package diff-hl :after magit :init (global-diff-hl-mode) :custom ;; If working via Tramp is slow, try setting the following: ;; (diff-hl-disable-on-remote t) :hook ((magit-pre-refresh . diff-hl-magit-pre-refresh) (magit-post-refresh . diff-hl-magit-post-refresh)) (vc-checkin . diff-hl-update) )
Note that if you don’t use Magit (yet…), the two lines from the :hook
section that refer to it can be removed, as well as the :after
line.
The project web site (https://github.com/dgutov/diff-hl) has some good screenshots that show what the result looks like, as well as more information on how to enable this in dired-mode
so you can see which files have changed when browsing files and directories in dired
.
No Comments