Chinaunix首页 | 论坛 | 博客
  • 博客访问: 140911
  • 博文数量: 116
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 20
  • 用 户 组: 普通用户
  • 注册时间: 2017-08-21 15:04
文章分类

全部博文(116)

文章存档

2014年(1)

2013年(13)

2012年(27)

2011年(49)

2010年(26)

分类: LINUX

2012-10-22 15:22:53

indent是一个很有用的c源代码对齐工具。一般大家有自己喜欢的风格,可以根据需要来设定indent的风格。

Linux Style是:

-nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -ce -ci4-cli0 -d0 -di1 -nfc1 -i8 -ip0 -l80 -lp -npcs -nprs -npsl -sai -saf -saw-ncs -nsc -sob -nfca -cp33 -ss -ts8 -il1

我采用的是类Linux Style:

indent -bad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -ce -ci4-cli0 -d0 -di1 -nfc1 -i4 -ip0 -l80 -lp -npcs -nprs -npsl -sai -saf -saw-ncs -nsc -nsob -nfca -cp33 -ss -ts8 -il1 file.c

-bad: –blank-lines-after-declarations,在变量声明后加一空行。

-bap: –blank-lines-after-procedures, 在函数后加空行。

-nbc: -bc的反,不会在变量声明的时候在每个逗号后面强制换行。

-bbo: 长行分行时将&&, || 之类的操作符放在行首。

-hnl: 分行在有&& ||时按优先级划分。

-br: --braces-on-if-line, 将{放在if语句同一行。

-brs: --braces-on-struct-decl-line, 将{放在struct关键字同一行。

-c33: --comment-indentationn,Put comments to the right of code in column n.

-cd33: --declaration-comment-columnn,Put comments to the right of the declarations in column n.

-ncdb: -cdb的反,不将注释的/*号单独放在一行。

-ce: 将if-then-else的else和{}放入同一行。

-ci4: 语句太长拆分成2句时,第二行相对第一行的缩进为4个字符。

-cli0: switch语句中,label对{的缩进为0。

-d0: --line-comments-indentationn,Set indentation of comments not to the right  of code to n spaces.

-di1: 声明时类型与变量名之间相距1个字符。

-nfc1: --dont-format-first-column-comments,Do not format comments in the first column as normal.

-i4: 每一级缩进4个字符。

-ip0: 老的函数声明使用,该处为了兼容。

-l80: --line-lengthn,一行代码为80个字符。

-lp: --continue-at-parentheses,Line up continued lines at parentheses.

-npcs: 括号紧跟在前面那个字符后。

-nprs: --space-after-parentheses的反,不在(后放空格。

-npsl: --procnames-start-lines的反,不用老式的函数声明风格,不将函数的返回类型放在函数名的前一行。

-sai: if与(间一个空格,默认选项。

-saf: for与(间一个空格,默认选项。

-saw: while与(间一个空格,默认选项。

-ncs: 不在强制转换的类型和变量名间加空格。

-nsc: 在多行注释中,不在每行注释前加*

-nsob: -sob(有些空行会在输出文件中被省略)的反,所有空行被copy。

-nfca: --dont-format-comments,不格式化任何注释。

-cp33: --else-endif-columnn,Put comments to the right of #else and #endif statements in column n.

-ss: 在while for语句中,将在 ; 后加空格。

-ts8: 被视为8个space。

-il1: --indent-labeln,Set offset for labels to column n.

参考文献:

[1]

[2]

阅读(1296) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~