给定文件 alfa.c :
#include <stdio.h>
int main() { // this is a comment
puts("hello world");
}
我可以像这样的GNU缩进格式化:
$ indent -st alfa.c
#include <stdio.h>
int
main ()
{ // this is a comment
puts ("hello world");
}
但是,该评论现在已经右边了。我确实尝试添加一个选项:
$ indent -st -c0 alfa.c
#include <stdio.h>
int
main ()
{ // this is a comment
puts ("hello world");
}
但这仍然不太正确。可以将缩进的方式援引评论仅在1或2个空间之后开始?
indent -c0 -nut -ts2
这将使您的所有选项卡更改为空格。
-c0在代码后删除评论的缩进(这将影响所有评论)。
编辑:缩小选项卡中的空间
它将注释一个选项卡放在撑杆之后。要解决这个问题,请设置标签大小,缩进并用空格替换选项卡。说我们希望标准缩进为3个空间
indent -st -c0 -i3 -ts3 -nut alfa.c