大括号和注释之间的间距
Spacing between brace and comment
给定文件 alfa.c:
#include <stdio.h>
int main() { // this is a comment
puts("hello world");
}
我可以像这样用 GNU Indent 格式化它:
$ 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 个空格后开始?
它把注释放在大括号后面一个制表符。要解决这个问题,请设置制表符大小、缩进并用空格替换制表符。假设我们希望标准缩进为 3 个空格
indent -st -c0 -i3 -ts3 -nut alfa.c
indent -c0 -nut -ts2
这会将您的所有制表符更改为空格。
-c0 删除代码后注释的缩进(因此这将影响所有注释)。
编辑:减少制表符中的空格
给定文件 alfa.c:
#include <stdio.h>
int main() { // this is a comment
puts("hello world");
}
我可以像这样用 GNU Indent 格式化它:
$ 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 个空格后开始?
它把注释放在大括号后面一个制表符。要解决这个问题,请设置制表符大小、缩进并用空格替换制表符。假设我们希望标准缩进为 3 个空格
indent -st -c0 -i3 -ts3 -nut alfa.c
indent -c0 -nut -ts2
这会将您的所有制表符更改为空格。
-c0 删除代码后注释的缩进(因此这将影响所有注释)。
编辑:减少制表符中的空格