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

📄 indent.texinfo

📁 indent为linux下代码自动格式化工具
💻 TEXINFO
📖 第 1 页 / 共 5 页
字号:
@kindex -bbb@kindex --blank-lines-before-block-comments@kindex -nbbb@kindex --no-blank-lines-before-block-commentsThe @option{-bbb} option forces a blank line before every boxed comment(@xref{Comments}.)The @option{-nbbb} option does not force such blank lines.@kindex -sob@kindex --swallow-optional-blank-lines@kindex -nsob@kindex --leave-optional-blank-linesThe @option{-sob} option causes @command{indent} to swallow optional blanklines (that is, any optional blank lines present in the input will beremoved from the output).  If the @option{-nsob} is specified, any blanklines present in the input file will be copied to the output file.@ifinfo@menu* -bad::                        More on the @option{-bad} option.* -bap::                        More on the @option{-bap} option.@end menu@end ifinfo@node -bad, -bap,  , Blank lines@comment  node-name,  next,  previous,  up@subsection --blank-lines-after-declarationsThe @option{-bad} option forces a blank line after every block ofdeclarations.  The @option{-nbad} option does not add any such blanklines.For example, given the input@example@groupchar *foo;char *bar;/* This separates blocks of declarations.  */int baz;@end group@end example@kindex -bad@kindex --blank-lines-after-declarations@kindex -nbad@kindex --no-blank-lines-after-declarations@noindent@code{indent -bad} produces@example@groupchar *foo;char *bar;/* This separates blocks of declarations.  */int baz;@end group@end example@noindentand @code{indent -nbad} produces@example@groupchar *foo;char *bar;/* This separates blocks of declarations.  */int baz;@end group@end example@node -bap,  , -bad, Blank lines@comment  node-name,  next,  previous,  up@subsection --blank-lines-after-procedures@kindex -bap@kindex --blank-lines-after-procedures@kindex -nbap@kindex --no-blank-lines-after-proceduresThe @option{-bap} option forces a blank line after every procedure body.For example, given the input@example@groupintfoo ()@{  puts("Hi");@}/* The procedure bar is even less interesting.  */char *bar ()@{  puts("Hello");@}@end group@end example@noindent@code{indent -bap} produces@example@groupintfoo ()@{  puts ("Hi");@}/* The procedure bar is even less interesting.  */char *bar ()@{  puts ("Hello");@}@end group@end example@noindent@c A better `group' would be better than `need'.@need 1250and @code{indent -nbap} produces@example@groupintfoo ()@{  puts ("Hi");@}/* The procedure bar is even less interesting.  */char *bar ()@{  puts ("Hello");@}@end group@end example@noindentNo blank line will be added after the procedure @code{foo}.@node Comments, Statements, Blank lines, Indent Program@comment  node-name,  next,  previous,  up@section Comments@cindex Comments@command{indent} formats both C and C++ comments. C comments are begun with@samp{/*}, terminated with @samp{*/} and may contain newline characters.C++ comments begin with the delimiter @samp{//} and end at the newline.@command{indent} handles comments differently depending upon their context.@command{indent} attempts to distinguish between comments which followstatements, comments which follow declarations, comments followingpreprocessor directives, and comments which are not preceded by code ofany sort, i.e., they begin the text of the line (although notneccessarily in column 1).@command{indent} further distinguishes between comments found outside ofprocedures and aggregates, and those found within them.  In particular,comments beginning a line found within a procedure will be indented tothe column at which code is currently indented.  The exception to this acomment beginning in the leftmost column;  such a comment is outputat that column.@command{indent} attempts to leave @dfn{boxed comments} unmodified.  Thegeneral idea of such a comment is that it is enclosed in a rectangle or``box'' of stars or dashes to visually set it apart.  More precisely,boxed comments are defined as those in which the initial @samp{/*} isfollowed immediately by the character @samp{*}, @samp{=}, @samp{_}, or@samp{-}, or those in which the beginning comment delimiter (@samp{/*})is on a line by itself, and the following line begins with a @samp{*} inthe same column as the star of the opening delimiter.Examples of boxed comments are:@example@group/********************** * Comment in a box!! * **********************/       /*        * A different kind of scent,        * for a different kind of comment.        */@end group@end example@command{indent} attempts to leave boxed comments exactly as they are foundin the source file.  Thus the indentation of the comment is unchanged,and its length is not checked in any way.  The only alteration made isthat an embedded tab character may be converted into the appropriatenumber of spaces.If the @option{-bbb} option is specified, all such boxed comments will bepreceded by a blank line, unless such a comment is preceded by code.@kindex -fca@kindex --format-all-comments@kindex -nfca@kindex --dont-format-comments@kindex -fc1@kindex --format-first-column-comments@kindex -nfc1@kindex --dont-format-first-column-commentsComments which are not boxed comments may be formatted, which means thatthe line is broken to fit within a right margin and left-filled withwhitespace.  Single newlines are equivalent to a space, but blank lines(two or more newlines in a row) are taken to mean a paragraph break.Formatting of comments which begin after the first column is enabledwith the @option{-fca} option.  To format those beginning in column one,specify @option{-fc1}.  Such formatting is disabled by default.The right margin for formatting defaults to 78, but may be changed withthe @option{-lc} option.  If the margin specified does not allow thecomment to be printed, the margin will be automatically extended for theduration of that comment.  The margin is not respected if the comment isnot being formatted.@kindex -d@var{n}@kindex --line-comments-indentation@var{n}If the comment begins a line (i.e., there is no program text to itsleft), it will be indented to the column it was found in unless thecomment is within a block of code.  In that case, such a comment will bealigned with the indented code of that block (unless the comment beganin the first column).  This alignment may be affected by the @option{-d}option, which specifies an amount by which such comments are moved tothe @emph{left}, or unindented.  For example, @option{-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 @option{-fc1}.@kindex -c@var{n}@kindex --comment-indentation@var{n}@kindex -cd@var{n}@kindex --declaration-comment-column@var{n}@kindex -cp@var{n}@kindex --else-endif-column@var{n}Comments to the right of code will appear by default in column 33.This may be changed with one of three options.  @option{-c} will specifythe column for comments following code, @option{-cd} specifies thecolumn for comments following declarations, and @option{-cp} specifiesthe column for comments following preprocessor directives @code{#else}and @code{#endif}.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.@kindex -cdb@kindex --comment-delimiters-on-blank-lines@kindex -ncdb@kindex --no-comment-delimiters-on-blank-linesThe @option{-cdb} option places the comment delimiters on blank lines.Thus, a single line comment like @code{/* Loving hug */} can betransformed into:@example@group/*   Loving hug */@end group@end example@kindex -sc@kindex --star-left-side-of-comments@kindex -nsc@kindex --dont-star-commentsStars can be placed at the beginning of multi-line comments with the@option{-sc} option.  Thus, the single-line comment above can betransformed (with @option{-cdb -sc}) into:@example@group/* * Loving hug */@end group@end example@node Statements, Declarations, Comments, Indent Program@comment  node-name,  next,  previous,  up@section Statements@kindex -br@kindex --braces-on-if-line@kindex -bl@kindex --braces-after-if-lineThe @option{-br} or @option{-bl} option specifies how to format braces.@c another paragraph that needs to be attached to its example.@need 650The @option{-br} option formats statement braces like this:@example@groupif (x > 0) @{  x--;@}@end group@end example@noindentThe @option{-bl} option formats them like this:@example@groupif (x > 0)  @{    x--;  @}@end group@end example@kindex -bli@var{n}@kindex --brace-indent@var{n}If you use the @option{-bl} option, you may also want to specify the@option{-bli} option.  This option specifies the number of spaces bywhich braces are indented.  @option{-bli2}, the default, gives theresult shown above.  @option{-bli0} results in the following:@example@groupif (x > 0)@{  x--;@}@end group@end example@kindex -ce@kindex --cuddle-else@kindex -dce@kindex --dont-cuddle-elseIf you are using the @option{-br} option, you probably want to also usethe @option{-ce} option.  This causes the @code{else} in an if-then-elseconstruct to cuddle up to the immediately preceding @samp{@}}.  Forexample, with @option{-br -ce} you get the following:@example@groupif (x > 0) @{  x--;@} else @{  fprintf (stderr, "...something wrong?\n");@}@end group@end example@noindentWith @option{-br -nce} that code would appear as@example@groupif (x > 0) @{  x--;@}else @{  fprintf (stderr, "...something wrong?\n");@}@end group@end example@kindex -cdw@kindex --cuddle-do-while@kindex -ncdw@kindex --dont-cuddle-do-whileThis causes the @code{while} in a do-whileloop to cuddle up to the immediately preceding @samp{@}}.  Forexample, with @option{-cdw} you get the following:@example@groupdo @{  x--;@} while (x);@end group@end example@noindentWith @option{-ncdw} that code would appear as@example@groupdo @{  x--;@}while (x);@end group@end example@kindex -cli@var{n}@kindex --case-indentation@var{n}The @option{-cli} option specifies the number of spaces that case labelsshould be indented to the right of the containing @code{switch}statement.@noindentThe default gives code like:@example@groupswitch (i)  @{  case 0:    break;  case 1:    @{      ++i;    @}  default:    break;  @}@end group

⌨️ 快捷键说明

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