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

📄 indent.texinfo

📁 indent为linux下代码自动格式化工具
💻 TEXINFO
📖 第 1 页 / 共 5 页
字号:
@end example@need 1550Using the @option{-cli2} that would become:@example@groupswitch (i)  @{    case 0:      break;    case 1:      @{        ++i;      @}    default:      break;  @}@end group@end example@kindex -cbi@var{n}@kindex --case-brace-indentation@var{n}The indentation of the braces below a case statement can becontrolled with the @option{-cbi@var{n}} option.  For example,using @option{-cli2 -cbi0} results in:@example@groupswitch (i)  @{    case 0:      break;    case 1:    @{      ++i;    @}    default:      break;  @}@end group@end example@kindex -ss@kindex --space-special-semicolon@kindex -nss@kindex --dont-space-special-semicolonIf a semicolon is on the same line as a @code{for} or @code{while}statement, the @option{-ss} option will cause a space to be placed beforethe semicolon.  This emphasizes the semicolon, making it clear that thebody of the @code{for} or @code{while} statement is an empty statement.@option{-nss} disables this feature.@kindex -pcs@kindex --space-after-procedure-calls@kindex -npcs@kindex --no-space-after-function-call-namesThe @option{-pcs} option causes a space to be placed between the name ofthe procedure being called and the @samp{(} (for example, @w{@code{puts("Hi");}}.  The @option{-npcs} option would give @code{puts("Hi");}).@refill@kindex -cs@kindex --space-after-cast@kindex -ncs@kindex --no-space-after-castsIf the @option{-cs} option is specified, @command{indent} puts a space aftera cast operator.@kindex -bs@kindex --blank-after-sizeofThe @option{-bs} option ensures that there is a space between thekeyword @code{sizeof} and its argument.  In some versions, this isknown as the @samp{Bill_Shannon} option.@kindex -saf@kindex --space-after-for@kindex -nsaf@kindex --no-space-after-forThe @option{-saf} option forces a space between an @code{for}and the following parenthesis.  This is the default.@kindex -sai@kindex --space-after-if@kindex -nsai@kindex --no-space-after-ifThe @option{-sai} option forces a space between an @code{if}and the following parenthesis.  This is the default.@kindex -saw@kindex --space-after-while@kindex -nsaw@kindex --no-space-after-whileThe @option{-saw} option forces a space between an @code{while}and the following parenthesis.  This is the default.@kindex -prs@kindex --space-after-parenthesesThe @option{-prs} option causes all parentheses to be seperated witha space from the what is between them.  For example, using @option{-prs}results in code like:@example@group  while ( ( e_code - s_code ) < ( dec_ind - 1 ) )    @{      set_buf_break ( bb_dec_ind );      *e_code++ = ' ';    @}@end group@end example@node Declarations, Indentation, Statements, Indent Program@comment  node-name,  next,  previous,  up@section Declarations@kindex -di@var{n}@kindex --declaration-indentation@var{n}By default @command{indent} will line up identifiers, in the columnspecified by the @option{-di} option.  For example, @option{-di16} makesthings look like:@example@groupint             foo;char           *bar;@end group@end exampleUsing a small value (such as one or two) for the @option{-di} option canbe used to cause the identifiers to be placed in the first availableposition; for example:@example@groupint foo;char *bar;@end group@end exampleThe value given to the @option{-di} option will still affect variableswhich are put on separate lines from their types, for example@option{-di2} will lead to:@example@groupint  foo;@end group@end example@kindex -bc@kindex --blank-lines-after-commas@kindex -nbc@kindex --no-blank-lines-after-commasIf the @option{-bc} option is specified, a newline is forced after eachcomma in a declaration.  For example,@example@groupint a,  b,  c;@end group@end example@noindentWith the @option{-nbc} option this would look like@exampleint a, b, c;@end example@kindex -bfda@kindex --break-function-decl-args@kindex -nbfda@kindex --dont-break-function-decl-args@kindex -bfde@kindex --break-function-decl-args-end@kindex -nbfde@kindex --dont-break-function-decl-args-endThe @option{-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 @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,@example@groupvoid foo (int arg1, char arg2, int *arg3, long arg4, char arg5);@end group@end example@noindentWith the @option{-bfda} option this would look like@examplevoid foo (    int arg1,    char arg2,    int *arg3,    long arg4,    char arg5);@end exampleWith, in addition, the @option{-bfde} option this would look like@examplevoid foo (    int arg1,    char arg2,    int *arg3,    long arg4,    char arg5    );@end example@kindex -psl@kindex --procnames-start-lines@kindex -npsl@kindex --dont-break-procedure-type@cindex @command{etags} requires @option{-psl}The @option{-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 @command{etags} program to work correctly, as well as someof the @code{c-mode} functions of Emacs.@kindex -T@cindex Typenames@cindex typedefYou must use the @option{-T}option to tell @command{indent} the name of all the typenames in yourprogram that are defined by @code{typedef}.  @option{-T} can be specifiedmore than once, and all names specified are used.  For example, if yourprogram contains@example@grouptypedef unsigned long CODE_ADDR;typedef enum @{red, blue, green@} COLOR;@end group@end example@noindentyou would use the options @option{-T CODE_ADDR -T COLOR}.The @option{-brs} or @option{-bls} option specifies how to format bracesin struct declarations.  The @option{-brs} option formats braces likethis:@example@groupstruct foo @{  int x;@};@end group@end example@noindentThe @option{-bls} option formats them like this:@example@groupstruct foo@{  int x;@};@end group@end example@node Indentation, Breaking long lines, Declarations, Indent Program@comment  node-name,  next,  previous,  up@section Indentation@kindex -i@var{n}@kindex --indent-level@var{n}@kindex -ci@var{n}@kindex --continuation-indentation@var{n}@kindex -lp@kindex --continue-at-parentheses@kindex -nlp@kindex --dont-line-up-parenthesesOne issue in the formatting of code is how far each line should beindented from the left margin.  When the beginning of a statement suchas @code{if} or @code{for} is encountered, the indentation level isincreased by the value specified by the @option{-i} option.  For example,use @option{-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 @option{-ci}option.  @option{-ci} defaults to 0.  However, if the @option{-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 @samp{[} and applies to @samp{@{} when it occurs in initializationlists.  For example, a piece of continued code might look like this with@option{-nlp -ci3} in effect:@example@group  p1 = first_procedure (second_procedure (p2, p3),     third_procedure (p4, p5));@end group@end example@noindentWith @option{-lp} in effect the code looks somewhat clearer:@example@group  p1 = first_procedure (second_procedure (p2, p3),                        third_procedure (p4, p5));@end group@end example@kindex -ts@var{n}@kindex --tab-size@var{n}When a statement is broken in between two or more paren pairs (...),each extra pair causes the indentation level extra indentation:@example@groupif ((((i < 2 &&        k > 0) || p == 0) &&    q == 1) ||  n = 0)@end group@end example@noindentThe option @option{-ip@var{N}} can be used to set the extra offset per paren.For instance, @option{-ip0} would format the above as:@example@groupif ((((i < 2 &&  k > 0) || p == 0) &&  q == 1) ||  n = 0)@end group@end example@noindent@command{indent} assumes that tabs are placed at regular intervals of bothinput and output character streams.  These intervals are by default 8columns wide, but (as of version 1.2) may be changed by the @option{-ts}option.  Tabs are treated as the equivalent number of spaces.@kindex -ip@var{n}@kindex --parameter-indentation@var{n}@kindex -nip@kindex --no-parameter-indentationThe indentation of type declarations in old-style function definitionsis controlled by the @option{-ip} parameter.  This is a numeric parameterspecifying how many spaces to indent type declarations.  For example,the default @w{@option{-ip5}} makes definitions look like this:@example@groupchar *create_world (x, y, scale)     int x;     int y;     float scale;@{  . . .@}@end group@end exampleFor compatibility with other versions of indent, the option @option{-nip}is provided, which is equivalent to @option{-ip0}.@kindex -lps@kindex --leave-preprocessor-space@kindex -nlps@kindex --remove-preprocessor-spaceANSI C allows white space to be placed on preprocessor command linesbetween the character @samp{#} and the command name.  By default,@command{indent} removes this space, but specifying the @option{-lps} optiondirects @command{indent} to leave this space unmodified. The option @option{-ppi} overrides  @option{-nlps} and  @option{-lps}.@kindex -ppi@var{n}@kindex --preprocessor-indentation@var{n}This option can be used to request that preprocessor conditional statements canbe indented by to given number of spaces, for example with the option @option{-ppi 3}@example@group#if X#if Y#define Z 1#else#define Z 0#endif#endif@end group@end examplebecomes@example@group#if X#   if Y#      define Z 1#   else#      define Z 0#   endif#endif@end group@end example@node Breaking long lines, Disabling Formatting, Indentation, Indent Program@comment  node-name,  next,  previous,  up@section Breaking long lines

⌨️ 快捷键说明

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