Trailing Whitespace

From WikEmacs
Revision as of 09: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, search

There are different ways to handle trailing whitespace in Emacs

Visualize trailing whitespace[edit]

Just set the show-trailing-whitespace variable:

(setq show-trailing-whitespace t)

Delete trailing whitespace[edit]

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[edit]