astyle格式化代码

Linux平台下:

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

(2) astyl.sh 脚本

#!/bin/bash

dir=`pwd`

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


for file in $filelist

do

     astyle --style=ansi -s4 -S -N -L -j -m0 -M40 --convert-tabs -n -U -H -p $file

done

(3)把这个脚本放在需要格式化的工程文件夹下,chmod  +x astyl.sh ,./astyl.sh 执行即可

 

Windows平台下:

1.下载astyle
2.将Astyle整个目录放到 C:\Program Files
3.将C:\Program Files\AStyle\bin 添加到环境变量中
    按照1,2,3,4,5,6的顺序

 

4. 将代码格式化.bat 拷贝到要格式化的目录下

代码格式化.bat:

for /R %%f in ( *.cpp;*.c;*.h ) do astyle.exe --style=ansi -s4 -S -N -L -j -m0 -M40 --convert-tabs -n "%%f"
pause


5.点击运行批处理,这个路径下包含子目录中的所有.c, .h, .cpp文件都被格式化

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值