搜档网
当前位置:搜档网 › source insight代码格式化

source insight代码格式化

source insight代码格式化
source insight代码格式化

source insight代码格式化(Astyle)

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

1、下载Astyle工具

在网站https://www.sodocs.net/doc/434476078.html,/projects/astyle/下载

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参数说明详见https://www.sodocs.net/doc/434476078.html,/astyle.html(官方文档)

在Source Insight集成PC lint(静态检查)

一、安装。

1。首先,将本目录下的文件全部拷贝到c:/lint之下。

2。然后,在Source InSight中,选择Option->Custom Commands...弹出“Custom Commands”窗口。

进行如下设置:

1)Command不要填,Name填PCLint

2)Run中填:C:/LINT/Lint-nt.exe-ic:/lint/std.lnt%f

3)选中以下复选框:

Iconic Window

Capture Output

Save Files First

Wait Until Done

Parse Links in Output

File,then Line

其他复选框不选。

4)Pattern中填:^/([a-zA-Z].*/)(/([0-9][0-9]*/)).*

然后点Add按钮。

3。最后设置快捷键。

点此窗口中的Keys...按钮,在Commands框中选“PCLint”,点"Add"按钮,然后敲一个热键。例如"Ctrl+ALT+p",没有冲突即可。最后点"OK"键。

4。在“Custom Commands”窗口中点"Change"按钮。

在Source Insight集成Astyle(代码格式化)

Windows平台下也有好多人都喜欢用SourceInsight编辑C/C++程序,但是SourceInsight 没有提供对代码格式化的功能,如果将Artistic Style

集成到SourceInsight中,那就可以为它扩展出代码格式化的功能了。

假定AStyle.exe的目录是“C:/ArtisticStyle/”,在该目录下有一个“c.opt”文件是用来保存配置的文件。下面简要地介绍下Artistic Style集

成到SourceInsight中的方法。

1.打开你的SourceInsight,选择菜单“Options-->Custom Commands-->Add”,输入Artistic Style(可以随便输入一个名字)。

2.Run中输入:E:/package/astyle/astyle.exe-KLmpb%f(注意路径不可以是中文的)

3.Dir留空,将Iconic Window,Pause when done,Wait until done,File,then Line四项前打上勾。

4.然后点对话框中右侧的按钮“Menu”,Menu--->Menu-->View-->,右侧Insert, OK.

5.此时在SourceInsight中的View菜单下多了个Style的子菜单选项,可以用它来对单个C/C++文件进行格式化。

相关主题