Say if I have the following:
func(arg1, arg2, arg3...)
func(longargarg1, longerarg2, arg3,...)
...
How do I align the arguments so that it's like following?
func(arg1 , arg2 , arg3...)
func(longargarg1, longerarg2, arg3,...)
...
[I can use M-x align-regex to align the first argument, but I cannot cook up with a suitable regex to align the rest of the arguments. Bonus point if the answer also take cares of the case when some arguments are strings with commas in them.]
Select the region, then:
C-u M-x align-regexp RET ,\(\s-*\) RET RET RET y
The regexp says to align commas with spaces following them. The default value of 1 for the paren group to modify means insert spaces where the \(\s-*\)
is, the default value of 1 for spaces to adjust means have one space after the longest expansion, and you want it repeated throughout the line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With