A lot of people aren’t familiar with some of the nice little ways Emacs helps you keep your text clean. Here are some handy commands related to manipulating whitespace that I use every day.
t causes Emacs to highlight any trailing whitespace
in the current buffer in the
face. Use the command
to delete such whitespace.
canonically-space-region can be used
to fix up the number of spaces between sentences, based on the
Whitespace around point
delete-horizontal-space, to which
M-\ is bound by default, obliterates
whitespace around point, leaving none. A very similar command,
just-one-space (available on
M-SPC), obliterates whitespace around
point, leaving exactly one space.