Difference between revisions of "Trailing Whitespace"

From WikEmacs
Jump to navigation Jump to search
(Page on trailing whitespace handling)
 
(No difference)

Latest revision as of 13:04, 31 July 2012

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