source insight代碼格式化(Astyle)
?GNU的astyle是一個免費的代碼格式化工具,能夠格式化c/c++等代碼 洋闽, 我們可以將Astyle.exe外掛到SourceInsight中,具體步驟如下:
1闯袒、下載Astyle工具
在網(wǎng)站http://astyle.sourceforge.net下載 或者?http://sourceforge.net/project/showfiles.php?group_id=2319l
2、source insight中掛載Astyle工具
a复凳、將AStyle_2.02_windows.zip解壓到D:\lb\目錄下(可以放在任意目錄)辰晕。
b、在SourceInsight菜單欄里舔清,Options-->Custom Commands界面上選擇:Add,在彈出對話框?qū)懭?命令名丝里,在run中添加相應(yīng)的命令。
? ? ??1)ansi C 格式化當前文件的命令為:"D:\Tools\AStyle_3.1_windows\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
????3)Linx C 格式化代碼的命令如下 "D:\Tools\AStyle_3.1_windows\AStyle\bin\Astyle.exe" --style=linux -t -S -N -L -m0 -M40 --convert-tabs --indent=force-tab=8 --suffix=.pre %f
TAB鍵為8個空格体谒,這個格式是我用來格式化編寫內(nèi)核代碼的時候用到的
reference如下
????c杯聚、在SourceInsight菜單欄里,Options-->Key Assignments 界面上選擇:Keys,在彈出對話框的Command框的列表中找到你定義的命令名抒痒,然后點擊Assign New Key幌绍,接著按下你要設(shè)置的快捷鍵。
3故响、Astyle參數(shù)說明
詳見http://astyle.sourceforge.net/astyle.html(官方文檔)