---
title: "在Source Insight集成Astyle（代码格式化）"
author: "Nonkr"
date: "2012-11-06T10:34:04Z"
tags: ["astyle", "sourceinsight"]
categories: ["非技术"]
slug: "source-insight-astyle"
draft: false
lastmod: "2013-06-20T16:00:58Z"
id: 1717305
url: "https://nonkr.iteye.com/blog/1717305"
---

Windows平台下也有好多人都喜欢用SourceInsight编辑C/C++程序，但是SourceInsight没有提供对代码格式化的功能，如果将Artistic Style集成到SourceInsight中，那就可以为它扩展出代码格式化的功能了。

假定AStyle.exe的目录是“C:/ArtisticStyle/”，在该目录下有一个“c.opt”文件是用来保存配置的文件。下面简要地介绍下Artistic Style集成到SourceInsight中的方法。  
1\. 打开你的SourceInsight, 选择菜单“Options--&gt;Custom Commands--&gt;Add”, 输入Artistic Style(可以随便输入一个名字)。  
2\. Run中输入: C:/ArtisticStyle/bin/astyle.exe -KLmpb %f （注意路径不可以是中文的）

3\. Dir留空，将Iconic Window, Pause when done, Wait until done, File,then Line 四项前打上勾。  
4\. 然后点对话框中右侧的按钮“Menu”， Menu---&gt;Menu--&gt;View--&gt;&lt;end of menu&gt;, 右侧Insert, OK.  
5\. 此时在SourceInsight中的View菜单下多了个Style的子菜单选项，可以用它来对单个C/C++文件进行格式化。