2

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:

Emacs 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?

  • 1
    For your first question: You can customize whitespace-space-regexp to only highlight leading spaces. See C-h v whitespace-space-regexp (or M-x describe-variable ...). The docs for whitespace-space-regexp contain an example of how to only highlight leading spaces. – Arnot Oct 9 '17 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.