zoukankan      html  css  js  c++  java
  • indent 用法

    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: <tab>被视为8个space。

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

    参考文献:

    [1] http://www.gnu.org/software/indent/

    [2] http://www.gnu.org/software/indent/manual/indent.html

    win下为 sourcestyle c++

  • 相关阅读:
    java Vamei快速教程02 方法和数据成员
    java Vamei快速教程01
    二叉树
    高效通信模型之
    高效通信模型之
    线程间通信与同步
    线程
    进程
    C++面试知识点总结
    windows下UDP服务器和客户端的实现
  • 原文地址:https://www.cnblogs.com/jjtx/p/2533507.html
Copyright © 2011-2022 走看看