Astyle代码格式化工具在IAR中的使用

1、Astyle下载路径:https://sourceforge.net/projects/astyle/files/?source=navbar



下载最新版Astyle解压到指定位置。

2、IAR中添加Astyle工具支持

打开IAR软件,选择Tools-->Config Tools

在Menu Text输入菜单名字

Command填写Astyle存放路径

Argument填写格式化参数:--style=ansi -s4 -S -Y  -D -xe -k1 -j  -c -xL  -p -U $FILE_PATH$

格式化代码的时候先选择需要格式化的文件即可。



  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
包含源代码,需要的可以自行下载。 把astyle.exe 复制到 C:\WINDOWS 目录里,省的指定路径 VC6++ 设置方法 菜单->工具->定制->工具菜单内容->新建菜单,参数如下 命令行:astyle.exe 变量: --style=k&r --brackets=break --indent=spaces --indent-cases --indent-preprocessor --pad-header --pad-oper --unpad-paren --keep-one-line-statements --keep-one-line-blocks --convert-tabs $(FileName)$(FileExt) 初始目录: $(FileDir) VC2008 外部工具里设置,还可以添加快捷键 命令:astyle.exe 参数: --style=k&r --brackets=break --indent=spaces --indent-cases --indent-preprocessor --pad-header --pad-oper --unpad-paren --keep-one-line-statements --keep-one-line-blocks --convert-tabs $(ItemFileName)$(ItemExt) 初始目录: $(ItemDir) CodeBlocks 设置差不多,很多绿色版的已经设置好了 AStyle_2.02_windows.zip bin 目录里有官方编译好的 Artistic Style 2.01 Maintained by: Jim Pattee Original Author: Tal Davidson Usage : astyle [options] Source1.cpp Source2.cpp [...] astyle [options] Beautified When indenting a specific file, the resulting indented file RETAINS the original file-name. The original pre-indented file is renamed, with a suffix of ".orig" added to the original filename. Wildcards (* and ?) may be used in the filename. A 'recursive' option can process directories recursively. By default, astyle is set up to indent C/C++/C#/Java files, with four spaces per indent, a maximal indentation of 40 spaces inside continuous statements, a minimum indentation of eight spaces inside conditional statements, and NO formatting options.
Source Insight是一个流行的用于编辑C/C++程序的工具,但它本身并没有提供代码格式化的功能。但是,我们可以通过集成Artistic Style工具来实现代码格式化的功能。 具体步骤如下: 1. 首先,确保你已经安装了Artistic Style工具,并且知道它的安装路径。 2. 打开Source Insight,并选择菜单的"Options->Custom Commands->Add"。 3. 在弹出的对话框,输入一个任意的名字,比如"Artistic Style"。 4. 在"Run"一栏,输入Artistic Style工具的路径和参数,例如:"C:/ArtisticStyle/Astyle.exe --options=c.opt %f"。这里,%f表示当前文件的路径。 5. 留空"Dir"一栏。 6. 在"Iconic Window","Capture Output","Parse Links in Output","File, then Line"这四项前打上勾。 7. 点击对话框右侧的"Menu"按钮。 8. 在弹出的菜单编辑界面,选择"Menu->Menu->View-><end of menu>"。 9. 点击右侧的"Insert"按钮,并点击"OK"保存更改。 10. 现在,在Source Insight的"View"菜单下会出现一个"Style"子菜单选项。你可以使用它来对单个C/C++文件进行格式化。 11. 如果你想要格式化代码片段,只需要选择代码然后执行格式化命令即可。如果你没有选择任何代码,只保留一个插入符,那么将对整个文件进行格式化。 通过以上步骤,你可以在Source Insight实现代码格式化的功能。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [source insight代码格式化](https://blog.csdn.net/wzk456/article/details/24302975)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [工具及方法 - 在Source Insight使用代码格式化工具](https://blog.csdn.net/guoqx/article/details/125437423)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值