Emacs Command to Delete Up to Non-Whitespace Character
You might try delete-indentation
, my favorite command for joining multiple lines into one line. In your example, put the cursor on the line with "second" and hit M-^ twice. Here are the docs:
M-^ runs the command
delete-indentation
, which is an interactive compiled Lisp function insimple.el
.It is bound to M-^.
(delete-indentation &optional arg)
Join this line to previous and fix up whitespace at join. If there is a fill prefix, delete it from the beginning of this line. With argument, join this line to following line.
Take a look at the fixup-whitespace
function. It comes with Emacs, in simple.el
. Its docs are:
Fixup white space between objects around point. Leave one space or none, according to the context.
A similar function, just-one-space
, that
Deletes all spaces and tabs around point, leaving one space
is typically bound to M-SPC.
Specifically, is there a command that will delete all whitespace from the point to the first non-whitespace character?
There's a command that does almost that:
M-\ runs the command delete-horizontal-space which is an interactive compiled Lisp function in `simple.el'.
It is bound to M-\.
(delete-horizontal-space &optional backward-only)
Delete all spaces and tabs around point. If backward-only is non-nil, only delete them before point.