0


使用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
标签: c语言 c++

本文转载自: https://blog.csdn.net/wwwlyj123321/article/details/119977063
版权归原作者 wwwlyj123321 所有, 如有侵权,请联系我们删除。

“使用ASTYLE格式化c/c++代码”的评论:

还没有评论