source insight代码格式化

source insight代码格式化(Astyle)

 GNU的astyle是一个免费的代码格式化工具,能够格式化c/c++等代码 , 我们可以将Astyle.exe外挂到SourceInsight中,具体步骤如下:

1、下载Astyle工具

在网站http://astyle.sourceforge.net下载 或者 http://sourceforge.net/project/showfiles.php?group_id=2319l

2、source insight中挂载Astyle工具

a、将AStyle_2.02_windows.zip解压到D:\lb\目录下(可以放在任意目录)。

b、在SourceInsight菜单栏里,Options-->Custom Commands界面上选择:Add,在弹出对话框写入 命令名,在run中添加相应的命令。

      1)ansi C 格式化当前文件的命令为:"D:\Tools\AStyle_3.1_windows\AStyle\bin\Astyle.exe" --style=ansi -s4 -S -N -L -m0 -M40 --convert-tabs --suffix=.pre %f 


       2)ansi C 格式化某个目录下所有文件的命令为:"D:\lb\AStyle\bin\Astyle.exe" Z:\LocalProject\DEZHOU3716/*.c Z:\LocalProject\DEZHOU3716/*.h --                         style=ansi -s4 -S -N -L -m0 -M40 --recursive --convert-tabs --suffix=.pre %f


    3)Linx C 格式化代码的命令如下 "D:\Tools\AStyle_3.1_windows\AStyle\bin\Astyle.exe" --style=linux -t -S -N -L -m0 -M40 --convert-tabs --indent=force-tab=8 --suffix=.pre %f

TAB键为8个空格,这个格式是我用来格式化编写内核代码的时候用到的

reference如下

    c、在SourceInsight菜单栏里,Options-->Key Assignments 界面上选择:Keys,在弹出对话框的Command框的列表中找到你定义的命令名,然后点击Assign New Key,接着按下你要设置的快捷键。


3、Astyle参数说明

详见http://astyle.sourceforge.net/astyle.html(官方文档)

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容