經常使用codeblock格式化代碼,但默認的情況下,運算符號前后不會添加空格,比如a=23,不會格式化成a = 23,因此有必要花一段時間來研究研究如何設置了。
codeblock 版本 10.05
格式化代碼的設置在:Settings-->>Editor..-->>source formatter
有三個選項卡,Style,Indentation,Formatting。Style處選擇一種預定義好了的樣式,如果不為Custom(自定義)則Indentation和Formatting處都將不可設置,Formatting處設置大部分的東西,Indentation處設置如何縮進
Style處選擇Custom,然后Formatting里重要的設置如下:
bracket format mode : 大括號{}的形式,
如果選break,將為 if()
{
}
如果選attach,將為if(){
}
none為不改變原有樣式,還有其它的兩個(略)
pointer alignment :指針*號的位置 int * a; or int* a; or int *a; or 不改變原有樣式
pad empty lines around header blocks : if等語句前后都添加一空行 int a;+換行+ if(1)a=23;+換行+int b; or int a;+換行+換行+if(1)a=23;+換行+換行+int b;
break 'else if()' header combinations into seperate lines : if()g(); or if()+換行+ g();
insert space padding around operatiors: '=' 等運算符前后都加1空格
insert space padding around parenthesies on the outside 括號外跟1空格
......................................................on the inside 括號內跟1空格
remove extra space padding around parenthesis : 移除括號旁邊其余的空格
don't break complex statements and multiple statement... : 允許多條語句同行。int a;int b; or int a;+換行+int b;
至於Indentation處的縮進(略)

