source insight代码格式化(Astyle)

来源:互联网 发布:ubuntu 源码安装mysql 编辑:程序博客网 时间:2024/05/16 09:33

source insight代码格式化(Astyle)

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


1、下载Astyle工具

在网站http://astyle.sourceforge.net下载

2、source insight中挂载Astyle工具

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

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

      1)ansi C 格式化当前文件的命令为:"D:\lb\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

            

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

        

3、Astyle参数说明详见http://astyle.sourceforge.net/astyle.html(官方文档)

原创粉丝点击