Define a command to strip trailing whitespace to all end of lines.
function! StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfunction
" You can of course rename the command however you wish.
command! StripTrailingWhitespaces call StripTrailingWhitespaces()