align-regexp
is called non-interactively like that:
(align-regexp BEG END REGEXP &optional GROUP SPACING REPEAT)
The argument REGEXP of align-regexp
is a regexp that should contain at least one group.
For alignment characters are deleted from the back of the substring matching the first group or whitespace is inserted at the back of that substring.
If you call align-regexp
interactively without prefix argument the actual argument REGEXP results from prepending the user-input with the string \(\s-*\)
. The effect is that space is inserted and deleted before the alignment character given in the user-input.
That is not what you want. You actually want :\(\s-*\)
as REGEXP.
If you call align-regexp
with prefix argument C-u you can input all arguments (required and optional) of align-regexp
literally. (BEG and END as beginning and end position of region).
I suggest you call C-u M-x align-regexp
with complex align regexp :\(\s-*\)
and default args otherwise (i.e., 1st group for aligning and 1 space) to get what you want.
C-u M-x align-regexp
with complex align regexp:\(\s-*\)
and default args otherwise (i.e., 1st group for aligning and 1 space) do exactly that?C-u
which stands forControl-u
. PressControl-u
and afterwardsMeta-x
and inputalign-regexp
enter...