1) expand 可以将 tab 转成空格
例如:foo.c 内容如下:
#include <stdio.h>$
#include <stdlib.h>$
int main(){$
^Iprintf("hello\n");$
^Ireturn 0;$
}$
使用 expand -t 2 foo.c # 1tab = 2 space
#include <stdio.h>
#include <stdlib.h>
int main(){
printf("hello\n");
return 0;
}
2) unexpand 将 空格转成 tab
例如 hello.c 内容如下:
#include <stdio.h>$
#include <stdlib.h>$
int main(){$
printf("hello\n");$
return 0;$
}$
使用 unexpand -t 4 hello.c # 4 space = 1 tab
#include <stdio.h>$
#include <stdlib.h>$
int main(){$
^Iprintf("hello\n");$
^Ireturn 0;$
}$