vimtricks.wiki Concise Vim tricks, one at a time.

How do you record a macro to remove trailing whitespace from lines?

Answer

qa:s/\s\+$//e\n jq

Explanation

Record a macro that runs a substitution on the current line to remove trailing spaces, then moves down. Repeat across all lines.

Next

How do you yank a single word into a named register?