Remove trailing whitespace
:%s/\s\+$//e
Example
Normal 0 / 2Command-line 1 / 2Normal 2 / 2one
two
threeCursor on line 1, column 1one
two
threeCursor on line 1, column 1one
two
threeCursor on line 2, column 1Match one or more whitespace characters at each line end.
Command entered · ready to apply
Match one or more whitespace characters at each line end
Before & after
one
two
threeCursor on line 1, column 1one
two
threeCursor on line 2, column 1Start in Normal mode, at line 1, column 1 (one-based). The percent range covers the file; e suppresses a no-match error. The example contains ordinary spaces. This example assumes gdefault and edcompatible are off. Type :%s/\s\+$//e and press Enter.
Details & Vim help
Example replayed in Vim
Match one or more whitespace characters at each line end.
The percent range covers the file; e suppresses a no-match error. The example contains ordinary spaces. This example assumes gdefault and edcompatible are off.