使用ASTYLE格式化c/c++代码

1、在notepad++中调用Astyle

点击,运行或是F5,

 

 输入调用的程序名称,如下所示:

C:\AStyle\bin\AStyle.exe --options=C:\AStyle\_astylerc   "$(FULL_CURRENT_PATH)" 

其中:

C:\AStyle\bin\AStyle.exe:表示应用程序文件存放的位置

--options=C:\AStyle\_astylerc:以文件的形式指定格式化的风格。文件会在下面提供,个人喜好不同,仅供参考。

"$(FULL_CURRENT_PATH)"是

NppExec插件所使用的语句,表示当前文件的绝对路径

输入完成后点击保存,弹出快捷键设置

 再次点击运行,就可以找到了

ref:

https://www.cnblogs.com/libra13179/p/9120360.html

2、在keil中调用astyle

和在notepad++中同理

 

3、在source insight中调用Astyle

在菜单栏选择 Tools找到Custom Commands

 

可以看见,新增一个astyle的cmd

 在run文本框中输入如下内容:

"C:\AStyle\bin\AStyle.exe" --options=C:\AStyle\_astylerc %f

其中:

"C:\AStyle\bin\AStyle.exe":表示应用程序文件存放的位置,要用双引号括起来

--options=C:\AStyle\_astylerc:以文件的形式指定格式化的风格。文件会在下面提供,个人喜好不同,仅供参考。

%f 表示格式化当前文件

 输入完成点击Menu按钮,弹出如下窗口,insert一个名为“astyle”的标签到Tools菜单栏(添加到菜单栏可以根据自己的喜好定制)

搞定! 

 

 

 

ref:

https://blog.csdn.net/gw_cs/article/details/7927735

 

附,_astylerc文件:

#--style=allman --mode=c -s4 -xV -S -xt3 -L -xW -w -xw -Y -m0 -M40 -f -p -P -xe -k3 -W3 -y -xb -j -c -xC130

--suffix=none

#-s4
--indent=spaces=4

--style=allman
#--style=linux
#--add-one-line-braces
#-j
--add-braces
#-y
--break-closing-braces


#-xV
--attach-closing-while
#-S
--indent-switches
#-xt3
--indent-continuation=3
#-L
--indent-labels
#-xW
--indent-preproc-block
#-w
--indent-preproc-define
--convert-tabs
#-xw
--indent-preproc-cond
#-Y
--indent-col1-comments
#-m0
--min-conditional-indent=0
#-M120
--max-continuation-indent=120


#Padding Options
#-U
--unpad-paren
#-f
#--break-blocks
#-p
--pad-oper
#-P
#--pad-paren
#-H
--pad-header
#-xe
#--delete-empty-lines
#-k3
--align-pointer=name
#-W3
--align-reference=name


#Formatting Options
#-xb
--break-one-line-headers
#-c
--convert-tabs
#-xC130
--max-code-length=130


--mode=c

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值