如何将参数对齐到emacs中的函数? [英] how to align arguments to functions in emacs?
问题描述
func(arg1,arg2,arg3 ...)
func (longargarg1,longerarg2,arg3,...)
...
调整参数,这样就像下面的那样?
func(arg1,arg2,arg3 ...)
func longargarg1,longerarg2,arg3,...)
...
[我可以使用Mx align-regex对齐第一个参数,但是我不能用适当的正则表达式来调整其余的参数。奖金点,如果答案也关心的情况下,一些参数是用逗号分隔的字符串。]
选择区域,然后:
Cu Mx align-regexp RET,\(\s- * \)RET RET RET y
正则表达式表示将逗号与其后面的空格对齐。默认值为1,为了更改括号组,意味着插入空格,其中 \(\s- * \)
是,空格的默认值为1调整手段在最长展开后有一个空格,您希望在整个行中重复。
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.
这篇关于如何将参数对齐到emacs中的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!