使用astyle格式化代码【脚本】

astyle使用基础教程 http://cppblog.com/jokes000/articles/158838.html

steps:

(1) apt-get install astyle 或者去主页http://sourceforge.net/projects/astyle下载

(2) astyl.sh 脚本

dir=`pwd`
filelist=`find $dir -type f -name "*.c" -or -name "*.h"`

for file in $filelist
do
    astyle --style=ansi --indent=spaces=4 $file
done    

(3)把这个脚本放在需要格式化的工程文件夹下,执行即可。

其他常用格式:

astyle --style=ansi --indent=tab
原文地址:https://www.cnblogs.com/mylinux/p/6125080.html