source insight自动对齐,安装Astyle

1.先说个小功能:让{ 和 } 不缩进:
Options -> Document Options -> Auto Indenting -> Auto Indent Type 选 Simple

2.安装Astyle

Astyle是一个用来对C/C++代码进行格式化的 Eclipse 插件,可在 Eclipse CDT 环境中使用。该插件基于 Artistic Style 开发。

其主页为http://astyle.sourceforge.net,目前最先版本AStyle_3.1_windows.zip,使用说明文档比较全面http://astyle.sourceforge.net/astyle.html#_default_bracket_style,可以查看对比使用。可以选择你喜欢的代码对齐或编写排版风格。

2.1、解压后将bin文件夹下的astyle.exe放到C:\Program Files (x86)\Source Insight 4.0\AStyle.exe目录下, 在SourceInsight菜单栏里,Tools-->Custom Commands界面 上选择:Add,在弹出对话框写入 Astyle。

2.2、在run中添加

"C:\Program Files (x86)\Source Insight 4.0\AStyle.exe" --style=ansi %f

参数--style=ansi 代表ansi C 格式(如果你需要格式化java代码,这个地方改为:--style=java),"%f"是指作用于当前文件。Dir留空,将Iconic Window, Capture Output, Parse Links in OutPut, File,then Line 四项前打上勾。  如下图所示。

2.3、在菜单中添加命令 ,option -> Menu Assignments ,在command中搜索Custom ,在menu中选择对应的地方,点insert,最后点OK

在需要整理格式的文件,点一下工具的Astyle就可以了。

image

要等一下过程有点慢

发布了6 篇原创文章 · 获赞 0 · 访问量 512

猜你喜欢

转载自blog.csdn.net/qq_34492122/article/details/104895658