I want to see all spaces at the beginning of a line as dots. Also tabs and line breaks. So I've set my init.el
file as the following:
(setq-default indent-tabs-mode nil)
(setq whitespace-style '(space-mark newline-mark tab-mark))
(whitespace-mode t)
(add-hook 'before-save-hook 'whitespace-cleanup)
(add-hook 'prog-mode-hook
(lambda ()
(whitespace-mode t)))
(add-hook 'text-mode-hook
(lambda ()
(whitespace-mode t)))
(setq whitespace-display-mappings
'((newline-mark 10 [172 10])
(space-mark 32 [183] [46])))
And that's the result:
You can see the desired effect for the line breaks and the dots here, but the dots are everywhere (Eg. between the words class
and Lottery
). I want only the leading spaces, actually to mark my indentation. How can I do that?
Also, how can I format the colors? I want to select a darker dot and line break. I know it's using a display table so faces won't work, right?
whitespace-space-regexp
to only highlight leading spaces. SeeC-h v whitespace-space-regexp
(orM-x describe-variable ...
). The docs forwhitespace-space-regexp
contain an example of how to only highlight leading spaces.whitespace-mode
, but do not want to visualize ALL spaces, then comment outspace-mark
in thewhitespace-style
setting. The doc-string for thewhitespace-style
variable contains an entry forspace-mark
that states: "SPACEs and HARD SPACEs are visualized via display table."