jcubic
jcubic

Reputation: 66620

How to highlight tabs in Emacs

I use spaces for indentation in source code, how can I highlight/mark tabs, that are in code?

It could be red, the same as when I use (setq-default show-trailing-whitespace t)

Upvotes: 9

Views: 4020

Answers (2)

Drew
Drew

Reputation: 30708

Just use command toggle-highlight-tabs from library highlight-chars.el.

Or you can turn on tab highlighting by default by adding function hc-highlight-tabs to font-lock-mode-hook in your init file:

(add-hook 'font-lock-mode-hook 'hc-highlight-tabs)

You can turn on/off the highlighting provided by library Highlight Chars:

  • in the current buffer only (i.e., locally),
  • globally whenever Font Lock mode is enabled, or
  • automatically whenever a buffer is in a given major mode

Upvotes: -1

jcubic
jcubic

Reputation: 66620

As a hint from @abo-abo I found that I can use whitespace-mode with this code:

(setq whitespace-style '(face tabs))
(whitespace-mode)

Upvotes: 9

Related Questions