Trailing Whitespace

From WikEmacs
Revision as of 13:04, 31 July 2012 by Francesco (talk | contribs) (Page on trailing whitespace handling)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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)))


See also