One task that often pops when editing text or code is the need to remove some extra whitespace around the point(the cursor). Emacs has your back!
First, we have the command
it deletes all spaces and tabs around the point. With a prefix
C-u M-\) the command deletes only the whitespace before the point.
One similar, although a bit less known, command is
M-SPC) - it deletes all spaces and tabs
around the point, leaving just one space (or
N spaces if you supply
N as a
prefix argument like
C-4 M-SPC). If
N is negative, the command
deletes newlines as well, leaving
One minor snafu with
just-one-space is that
M-SPC is a no-go on
OSX since just about everyone uses it for quick access to Spotlight or
switching between languages. You might want to use a different
keybinding like this one:
(global-set-key (kbd "C-c j") 'just-one-space)
Personally, of the two commands I find
just-one-space the more useful.