In vim:
:%s/\s\+$//
Explanation:
:command%apply to entire filessearch and replace/\s\+$/regex for one or more whitespace characters followed by the end of a line//replacement value of an empty string
In vim:
:%s/\s\+$//
Explanation:
: command% apply to entire files search and replace/\s\+$/ regex for one or more whitespace characters followed by the end of a line// replacement value of an empty string