ubuntu安装indent:
sudo apt-get install indent
示例:
随便写一个代码1.c:
#include <stdio.h>
int main()
{
printf("Hello");
if(1==1)
{
printf("World");
}
else{
printf("!");
}
return 0;
}
执行命令:
indent -br 1.c -o 2.c
得到代码2.c:
#include <stdio.h>
int
main ()
{
printf ("Hello");
if (1 == 1) {
printf ("World");
}
else {
printf ("!");
}
return 0;
}
执行命令:
indent -bli0 1.c -o 3.c
得到代码3.c:
#include <stdio.h>
int
main ()
{
printf ("Hello");
if (1 == 1)
{
printf ("World");
}
else
{
printf ("!");
}
return 0;
}
执行命令:
indent -linux 1.c -o 4.c
得到代码4.c(以Tab进行缩进):
#include <stdio.h>
int main()
{
printf("Hello");
if (1 == 1) {
printf("World");
} else {
printf("!");
}
return 0;
}
运行命令:
indent -orig -i4 -ts0 1.c -o 5.c
得到代码5.c(Tab使用4个空格替代):
#include <stdio.h>
int
main()
{
printf("Hello");
if (1 == 1) {
printf("World");
} else {
printf("!");
}
return 0;
}