排版工具:gnu indent 【转】

原文:http://blog.chinaunix.net/uid-20662363-id-1904146.html

参考: http://www.worldhello.net/doc/program_rules/indent.html

google搜索就能找到gnu indent.

The `indent' program can be used to make code easier to read. It can also convert from one style of writing C to another.

 

参照GNU,Kernighan & Ritchie,Berkeley风格,制定了自己风格:

  1. indent命令参数:

    -bad -bap -bbb -bbo -nbc -bl -bli0 -bls -c33 -cd33 -ncdb -ncdw -nce -cli0 -cp33 -cs -d0 -nbfda -di2 -nfc1 -nfca -hnl -ip5 -l75 -lp -pcs -nprs -psl -saf -sai -saw -nsc -nsob -nss -i4 -ts4 -ut

  2. indent配置文件

    如上参数可写入用户目录下的文件:".indent.pro",作为运行indent的确省参数。

  3. indent配置说明

    Indent代码格式化说明
    使用的indent参数含义
    --blank-lines-after-declarationsbad变量声明后加空行
    --blank-lines-after-proceduresbap函数结束后加空行
    --blank-lines-before-block-commentsbbb块注释前加空行
    --break-before-boolean-operatorbbo较长的行,在逻辑运算符前分行
    --blank-lines-after-commasnbc变量声明中,逗号分隔的变量不分行
    --braces-after-if-linebl"if"和"{"分做两行
    --brace-indent 0bli0"{"不继续缩进
    --braces-after-struct-decl-linebls定义结构,"struct"和"{"分行
    --comment-indentationnc33语句后注释开始于行33
    --declaration-comment-columnncd33变量声明后注释开始于行33
    --comment-delimiters-on-blank-linesncdb不将单行注释变为块注释
    --cuddle-do-whilencdw"do --- while"的"while"和其前面的"}"另起一行
    --cuddle-elsence"else"和其前面的"}"另起一行
    --case-indentation 0cli0switch中的case语句所进0个空格
    --else-endif-columnncp33#else, #endif后面的注释开始于行33
    --space-after-castcs在类型转换后面加空格
    --line-comments-indentation nd0单行注释(不从1列开始的),不向左缩进
    --break-function-decl-argsnbfda关闭:函数的参数一个一行
    --declaration-indentationndi2变量声明,变量开始于2行,即不必对齐
    --format-first-column-commentsnfc1不格式化起于第一行的注释
    --format-all-commentsnfca不开启全部格式化注释的开关
    --honour-newlineshnlPrefer to break long lines at the position of newlines in the input.
    --indent-levelni4设置缩进多少字符,如果为tab的整数倍,用tab来缩进,否则用空格填充。
    --parameter-indentationnip5旧风格的函数定义中参数说明缩进5个空格
    --line-length 75l75非注释行最长75
    --continue-at-parentheseslp续行从上一行出现的括号开始
    --space-after-procedure-callspcs函数和"("之间插入一个空格
    --space-after-parenthesesnprs在"("后")"前不插入空格
    --procnames-start-linespsl将函数名和返回类型放在两行定义
    --space-after-forsaffor后面有空格
    --space-after-ifsaiif后面有空格
    --space-after-whilesawwhile后面有空格
    --start-left-side-of-commentsnsc不在生成的块注释中加*
    --swallow-optional-blank-linesnsob不去掉可添加的空行
    --space-special-semicolonnss一行的for或while语句,在";"前不加空。
    --tab-sizets4一个tab为4个空格(要能整除"-in")
    --use-tabsut使用tab来缩进

转载于:https://www.cnblogs.com/Leo-Forest/archive/2012/11/02/2751787.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值