Trailing Whitespace
Jump to navigation
Jump to search
There are different ways to handle trailing whitespace in Emacs
Visualize trailing whitespace
Just set the show-trailing-whitespace variable:
(setq show-trailing-whitespace t)
Delete trailing whitespace
You can delete trailing whitespace in the entire buffer using M-x delete-trailing-whitespace.
To automate trailing whitespace deletion before saving the buffer in certain modes, you can add local hooks, e.g:
(add-hook 'c-mode-hook (lambda () (add-to-list 'write-file-functions 'delete-trailing-whitespace)))