I'm using the flake8 linter for Python, which constantly complains about whitespace on empty lines and trailing whitespace on non-empty lines.

How can I configure Vim to automatically remove such whitespace, e.g. whenever I save the file?

Is there any good plugin for performing this operation?

Browse other questions tagged or ask your own question.