如何在 emacs 中将参数与函数对齐?
假设我有以下情况:
func(arg1, arg2, arg3...)
func(longargarg1, longerarg2, arg3,...)
...
如何对齐参数,使其如下所示?
func(arg1 , arg2 , arg3...)
func(longargarg1, longerarg2, arg3,...)
...
[我可以使用 Mxalign-regex 来对齐第一个参数,但我无法使用合适的正则表达式来对齐其余参数。 如果答案也考虑到某些参数是带有逗号的字符串的情况,那就加分了。]
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.]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
选择区域,然后:
正则表达式表示将逗号与其后面的空格对齐。 括号组修改默认值1表示在
\(\s-*\)
所在位置插入空格,调整空格默认值1表示最长扩展后有一个空格,并且您希望它在整行中重复。Select the region, then:
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.