I delete trailing whitespace a lot, especially as the project I'm most involved in at work passes all commits through a linter and it rejects trailing whitespace!
Funny though -- as much as I do this, it never occurred to me to make a macro for it.
The way I've done it for ever (my fingers might break if I try a different way) is:
^j 1 # To get to the top of the file
^a # to get to the left edge
Ctrl-Shift-_ # bring up a regex search
[ I]+$ # Note: the "I" is a literal Tab character. Hit the Tab key on the prompt. Took me 10 years to figure that out.
The "$" matches the end-of-line. The "[ I]+" matches a string of one or more spaces and tabs.
If it finds any lines with trailing whitespace, then hit ^R to replace. Make sure the response to the prompt is empty, and hit Enter.
Or better yet, hit ^k to get to the command line, then enter
RA ""
That's the ReplaceAll command with a quoted empty string as the parameter. It should come back with a message like "2 replacements made."
Making a macro that puts you back where you were will involve setting a bookmark, so you'd want a convention for your bookmarks that reserves one for macros like this. Maybe. Or if you don't use many bookmarks and you don't care, then no big deal. Maybe the best option is to use the automatic bookmark "-" so you don't mess up any of your numbered bookmarks.
It's important to make a macro that isn't going to fail half-way throug. If you do a FindRegEx for trailing whitespace, and there isn't any, then the macro is going to stop right there and not return you to your bookmarked starting place.
The solution to that problem is to ensure there's some trailing whitespace! The downside, if you care, is that the document will always end up being marked as changed after running this macro. So, here's my cut at a TWS (Trailing White Space) macro:
PushPrefs
SearchBack 0
SetBookmark -
MoveEOL
InsertString " "
GotoLine 1
MoveSOL
FindRegExp [ ]+$
ReplaceAll ""
GotoBookmark -
PopPrefs
Again, inside the BindRegExp brackets are a single space and a literal Tab character.
Give that a try and see how you like it.