M-\\
(M-x delete-horizontal-space
) removes all spaces between non-spaces.
But this key binding is not convenient to strike and remember...
There is a similar key binding M-SPC
(just-one-space
) - remove all spaces and add one.
In 2013-01-30 Michal Nazarewicz introduced a new function cycle-spacing
that combines both
just-one-space
and delete-horizontal-space
by cycling between one space, no space and
original spacing.
Now I have in my .emacs
:
(when (fboundp 'cycle-spacing) (global-set-key (kbd "M-SPC") 'cycle-spacing))