With indent-tabs-mode
set to nil
1, the following will do most of that:
C-uM-x align-regexp
RET ,\(\s-*\)
RET RET y
Dealing with the initial parameter is decidedly trickier. If you can guarantee the presence of a space after each comma, then you could use the following regexp along with 0
for the "Amount of spacing" question:
\(?:, \|^\(?://\|.*?(\)\)\(\s-*\)
You may prefer to use a two-step process, though. e.g.:
^\(?://\|.*?(\)\(\s-*\)
with spacing = 0
, and not repeating; followed by
,\(\s-*\)
with spacing = 1
, and repeating
You should probably elaborate on the kind of workflow you're looking for, though. Are you looking for a command to call manually? Automated alignment rules? Something to use occasionally via a keyboard macro? Other?
1 I would recommend using the following in general:
;; Align with spaces only
(defadvice align-regexp (around align-regexp-with-spaces)
"Never use tabs for alignment."
(let ((indent-tabs-mode nil))
ad-do-it))
(ad-activate 'align-regexp)