Deleting trailing whitespace automatically in emacs

cpplint gripes if there’s trailing whitespace, but Daniel found
a way to remove it automatically with emacs:

Here’s the link to info:

Here are the lines that I added to my .emacs file (I just enabled it for C++. I might want to do it for latex too):

(add-hook 'c++-mode-hook
           (lambda () (add-to-list 'write-file-functions 'delete-trailing-whitespace)))
1 Like