如何将参数与 emacs 中的函数对齐? [英] how to align arguments to functions in emacs?

查看:13
本文介绍了如何将参数与 emacs 中的函数对齐?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有以下几点:

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,...)
...

[我可以使用 M-x align-regex 来对齐第一个参数,但我无法使用合适的正则表达式来对齐其余参数.如果答案还考虑了某些参数是其中包含逗号的字符串的情况,则加分项.]

[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.]

推荐答案

选择地区,然后:

C-u M-x align-regexp RET ,(s-*) RET RET RET y

正则表达式表示将逗号与后面的空格对齐.要修改的paren组默认值为1表示在(s-*)所在的位置插入空格,要调整的空格默认值为1表示在最长扩展后留一个​​空格,并且您希望它在整行中重复.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆