作为一名测试工程师,我经常有一些像下面这样的意大利面条代码:
int *const cpe = &n; assert(42 == *cpe);
int *const cpf = &cn; assert(42 == *cpf);
int *const cpg = pcn; assert(42 == *cpg);
int *const cph = cpcn; assert(42 == *cph);
为了美观,我想将它们按“;”定义的列对齐,如下所示:
int *const cpe = &n; assert(42 == *cpe);
int *const cpf = &cn; assert(42 == *cpf);
int *const cpg = pcn; assert(42 == *cpg);
int *const cph = cpcn; assert(42 == *cph);
emacs 有办法做到这一点吗? (我知道 M-x align 但它并没有像期望的那样做得很好。) 希望该方法也适用于“,”。
最佳答案
(add-to-list 'align-rules-list
'(c-assignment1
(regexp . "[=;]\\(\\s-*\\)")
(mode . '(c-mode))
(repeat . t)))
如果您编写这段代码,M-x align
也可以。
关于c++ - 如何将 emacs C++ 模式下的代码对齐到 ";"或 ","?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24471509/