⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 indent.1

📁 indent为linux下代码自动格式化工具
💻 1
📖 第 1 页 / 共 4 页
字号:
the \fIleft\fR, or unindented.  For example, \`-d2\' places commentstwo spaces to the left of code.  By default, comments are aligned withcode, unless they begin in the first column, in which case they are leftthere by default --- to get them aligned with the code, specify \`-fc1\'.Comments to the right of code will appear by default in column 33.This may be changed with one of three options.  \`-c\' will specifythe column for comments following code, \`-cd\' specifies thecolumn for comments following declarations, and \`-cp\' specifiesthe column for comments following preprocessor directives \fB#else\fRand \fB#endif\fR.If the code to the left of the comment exceeds the beginning column,the comment column will be extended to the next tabstop column pastthe end of the code, or in the case of preprocessor directives, to onespace past the end of the directive.  This extension lasts only forthe output of that particular comment.The \`-cdb\' option places the comment delimiters on blank lines.Thus, a single line comment like \fB/* Loving hug */\fR can betransformed into:.in +5.nf.na/*   Loving hug */.in -5.ad.fiStars can be placed at the beginning of multi-line comments with the\`-sc\' option.  Thus, the single-line comment above can betransformed (with \`-cdb -sc\') into:.in +5.nf.na/* * Loving hug */.in -5.ad.fi.SH "STATEMENTS"The \`-br\' or \`-bl\' option specifies how to format braces.The \`-br\' option formats statement braces like this:.in +5.nf.naif (x > 0) {  x--;}.in -5.ad.fiThe \`-bl\' option formats them like this:.in +5.nf.naif (x > 0)  {    x--;  }.in -5.ad.fiIf you use the \`-bl\' option, you may also want to specify the\`-bli\' option.  This option specifies the number of spaces bywhich braces are indented.  \`-bli2\', the default, gives theresult shown above.  \`-bli0\' results in the following:.in +5.nf.naif (x > 0){  x--;}.in -5.ad.fiIf you are using the \`-br\' option, you probably want to also usethe \`-ce\' option.  This causes the \fBelse\fR in an if-then-elseconstruct to cuddle up to the immediately preceding \`}\'.  Forexample, with \`-br -ce\' you get the following:.in +5.nf.naif (x > 0) {  x--;} else {  fprintf (stderr, "...something wrong?\\n");}.in -5.ad.fiWith \`-br -nce\' that code would appear as.in +5.nf.naif (x > 0) {  x--;}else {  fprintf (stderr, "...something wrong?\\n");}.in -5.ad.fiThis causes the \fBwhile\fR in a do-whileloop to cuddle up to the immediately preceding \`}\'.  Forexample, with \`-cdw\' you get the following:.in +5.nf.nado {  x--;} while (x);.in -5.ad.fiWith \`-ncdw\' that code would appear as.in +5.nf.nado {  x--;}while (x);.in -5.ad.fiThe \`-cli\' option specifies the number of spaces that case labelsshould be indented to the right of the containing \fBswitch\fRstatement.The default gives code like:.in +5.nf.naswitch (i)  {  case 0:    break;  case 1:    {      ++i;    }  default:    break;  }.in -5.ad.fiUsing the \`-cli2\' that would become:.in +5.nf.naswitch (i)  {    case 0:      break;    case 1:      {        ++i;      }    default:      break;  }.in -5.ad.fiThe indentation of the braces below a case statement can becontrolled with the \`-cbi\fIn\fR\' option.  For example,using \`-cli2 -cbi0\' results in:.in +5.nf.naswitch (i)  {    case 0:      break;    case 1:    {      ++i;    }    default:      break;  }.in -5.ad.fiIf a semicolon is on the same line as a \fBfor\fR or \fBwhile\fRstatement, the \`-ss\' option will cause a space to be placed beforethe semicolon.  This emphasizes the semicolon, making it clear that thebody of the \fBfor\fR or \fBwhile\fR statement is an empty statement.\`-nss\' disables this feature.The \`-pcs\' option causes a space to be placed between the name ofthe procedure being called and the \`(\' (for example, \fBputs\ ("Hi");\fR.  The \`-npcs\' option would give \fBputs("Hi");\fR).If the \`-cs\' option is specified, \fBindent\fR puts a space aftera cast operator.The \`-bs\' option ensures that there is a space between thekeyword \fBsizeof\fR and its argument.  In some versions, this isknown as the \`Bill_Shannon\' option.The \`-saf\' option forces a space between an \fBfor\fRand the following parenthesis.  This is the default.The \`-sai\' option forces a space between an \fBif\fRand the following parenthesis.  This is the default.The \`-saw\' option forces a space between an \fBwhile\fRand the following parenthesis.  This is the default.The \`-prs\' option causes all parentheses to be seperated witha space from the what is between them.  For example, using \`-prs\'results in code like:.in +5.nf.na  while ( ( e_code - s_code ) < ( dec_ind - 1 ) )    {      set_buf_break ( bb_dec_ind );      *e_code++ = \' \';    }.in -5.ad.fi.SH "DECLARATIONS"By default \fBindent\fR will line up identifiers, in the columnspecified by the \`-di\' option.  For example, \`-di16\' makesthings look like:.in +5.nf.naint             foo;char           *bar;.in -5.ad.fiUsing a small value (such as one or two) for the \`-di\' option canbe used to cause the identifiers to be placed in the first availableposition; for example:.in +5.nf.naint foo;char *bar;.in -5.ad.fiThe value given to the \`-di\' option will still affect variableswhich are put on separate lines from their types, for example\`-di2\' will lead to:.in +5.nf.naint  foo;.in -5.ad.fiIf the \`-bc\' option is specified, a newline is forced after eachcomma in a declaration.  For example,.in +5.nf.naint a,  b,  c;.in -5.ad.fiWith the \`-nbc\' option this would look like.in +5.nf.naint a, b, c;.in -5.ad.fiThe \`-bfda\' option causes a newline to be forced after the commaseparating the arguments of a function declaration.  The arguments willappear at one indention level deeper than the function declaration.  This is particularly helpful for functions with long argument lists. The option \`-bfde\' causes a newline to be forced before the closing bracket of the function declaration. For both options the \'n\' setting is the default:-nbdfa and -nbdfe.For example,.in +5.nf.navoid foo (int arg1, char arg2, int *arg3, long arg4, char arg5);.in -5.ad.fiWith the \`-bfda\' option this would look like.in +5.nf.navoid foo (    int arg1,    char arg2,    int *arg3,    long arg4,    char arg5);.in -5.ad.fiWith, in addition, the \`-bfde\' option this would look like.in +5.nf.navoid foo (    int arg1,    char arg2,    int *arg3,    long arg4,    char arg5    );.in -5.ad.fiThe \`-psl\' option causes the type of a procedure being defined tobe placed on the line before the name of the procedure.  This style isrequired for the \fBetags\fR program to work correctly, as well as someof the \fBc-mode\fR functions of Emacs.You must use the \`-T\'option to tell \fBindent\fR the name of all the typenames in yourprogram that are defined by \fBtypedef\fR.  \`-T\' can be specifiedmore than once, and all names specified are used.  For example, if yourprogram contains.in +5.nf.natypedef unsigned long CODE_ADDR;typedef enum {red, blue, green} COLOR;.in -5.ad.fiyou would use the options \`-T CODE_ADDR -T COLOR\'.The \`-brs\' or \`-bls\' option specifies how to format bracesin struct declarations.  The \`-brs\' option formats braces likethis:.in +5.nf.nastruct foo {  int x;};.in -5.ad.fiThe \`-bls\' option formats them like this:.in +5.nf.nastruct foo{  int x;};.in -5.ad.fi.SH "INDENTATION"One issue in the formatting of code is how far each line should beindented from the left margin.  When the beginning of a statement suchas \fBif\fR or \fBfor\fR is encountered, the indentation level isincreased by the value specified by the \`-i\' option.  For example,use \`-i8\' to specify an eight character indentation for eachlevel.  When a statement is broken across two lines, the second line isindented by a number of additional spaces specified by the \`-ci\'option.  \`-ci\' defaults to 0.  However, if the \`-lp\' option isspecified, and a line has a left parenthesis which is not closed on thatline, then continuation lines will be lined up to start at the characterposition just after the left parenthesis.  This processing also appliesto \`[\' and applies to \`{\' when it occurs in initializationlists.  For example, a piece of continued code might look like this with

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -