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

要等一下過程有點慢

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章