emacs垂直对齐功能参数 [英] emacs align function parameters vertically

查看:240
本文介绍了emacs垂直对齐功能参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现以下功能:

I'm trying to achieve the following:

void foo( int one,
int const & two,
Bar three)

void foo( int          one,
          inst const & two,
          Bar          three)

这是否可以使用 align-regex 函数(与我们没有前缀)?

Is this possible to do using the align-regex function (with our without prefix)?

更一般来说,正则表达式中的分组意味着什么(被认为是列的部分)?什么是'括号组修改(对齐为否定)'?

More generally, what does the grouping in the regex signify (is it the part that's considered the 'column')? And what is the 'parentheses group to modify (justify if negative)'?

谢谢

推荐答案

请参阅 Ch f align-regexp RET 特别是链接的 Ch v align-rules-list RET 的最佳文档对齐。

See C-hf align-regexp RET and, in particular, the linked C-hv align-rules-list RET which provides some of the best documentation for alignment.

要修改的组是指在对齐时将被缩小或扩展的模式中的组。你几乎总是希望这个组是纯粹的空格,以避免删除实际的内容。

The "group to modify" means the group in the pattern which will be shrunk or expanded when aligning. You almost always want this group to be purely whitespace, in order to avoid deleting actual content.

GROUP参数 - 交互式的括号组修改(对齐为否) - 是正则表达式中的组数,从1开始计数。

The GROUP argument -- interactively "Parentheses group to modify (justify if negative)" -- is the number of the group in question in the regexp, counting from 1.

调整部分有点棘手。如果您提供一个负数,则使用相同的组,就好像该数字是正数,但也会触发 align-rules-list 变量的对齐行为:

The justification part is a bit trickier. If you provide a negative number, then the same group is used as if the number were positive, but the 'justify' behaviour of the align-rules-list variable is also triggered:

`justify'
It is possible with `regexp' and `group' to identify a
character group that contains more than just whitespace
characters.  By default, any non-whitespace characters in
that group will also be deleted while aligning the
alignment character.  However, if the `justify' attribute
is set to a non-nil value, only the initial whitespace
characters within that group will be deleted.  This has
the effect of right-justifying the characters that remain,
and can be used for outdenting or just plain old right-
justification.

这篇关于emacs垂直对齐功能参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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