📄 indent.texinfo
字号:
@kindex -l@var{n}@kindex --line-length@var{n}With the option @option{-l@var{n}}, or @option{--line-length@var{n}}, it ispossible to specify the maximum length of a line of C code, not includingpossible comments that follow it.When lines become longer then the specified line length, GNU @command{indent}tries to break the line at a logical place. This is new as of version 2.1however and not very intelligent or flexible yet.@kindex -bbo@kindex --break-before-boolean-operator@kindex -nbbo@kindex --break-after-boolean-operator@kindex -hnl@kindex --honour-newlines@kindex -nhnl@kindex --ignore-newlinesCurrently there are two options that allows one to interfere with thealgorithm that determines where to break a line.The @option{-bbo} option causes GNU @command{indent} to prefer to breaklong lines before the boolean operators @code{&&} and @code{||}. The@option{-nbbo} option causes GNU @command{indent} not have thatpreference. For example, the default option @option{-bbo} (togetherwith @option{--line-length60} and @option{--ignore-newlines}) makes codelook like this:@example@group if (mask && ((mask[0] == '\0') || (mask[1] == '\0' && ((mask[0] == '0') || (mask[0] == '*')))))@end group@end exampleUsing the option @option{-nbbo} will make it look like this:@example@group if (mask && ((mask[0] == '\0') || (mask[1] == '\0' && ((mask[0] == '0') || (mask[0] == '*')))))@end group@end exampleThe default @option{-hnl}, however, honours newlines in the input file bygiving them the highest possible priority to break lines at. For example,when the input file looks like this:@example@group if (mask && ((mask[0] == '\0') || (mask[1] == '\0' && ((mask[0] == '0') || (mask[0] == '*')))))@end group@end example@noindentthen using the option @option{-hnl}, or @option{--honour-newlines},together with the previously mentioned @option{-nbbo} and@option{--line-length60}, will cause the output not to be what is givenin the last example but instead will prefer to break at the positionswhere the code was broken in the input file:@example@group if (mask && ((mask[0] == '\0') || (mask[1] == '\0' && ((mask[0] == '0') || (mask[0] == '*')))))@end group@end exampleThe idea behind this option is that lines which are too long, but are alreadybroken up, will not be touched by GNU @command{indent}. Really messy codeshould be run through @command{indent} at least once using the@option{--ignore-newlines} option though.@node Disabling Formatting, Miscellaneous options, Breaking long lines, Indent Program@comment node-name, next, previous, up@section Disabling FormattingFormatting of C code may be disabled for portions of a program byembedding special @dfn{control comments} in the program. To turn offformatting for a section of a program, place the disabling controlcomment @code{/* *INDENT-OFF* */} on a line by itself just before thatsection. Program text scanned after this control comment is outputprecisely as input with no modifications until the correspondingenabling comment is scanned on a line by itself. The disabling controlcomment is @code{/* *INDENT-ON* */}, and any text following the commenton the line is also output unformatted. Formatting begins again withthe input line following the enabling control comment.More precisely, @command{indent} does not attempt to verify the closingdelimiter (@code{*/}) for these C comments, and any whitespace on theline is totally transparent.These control comments also function in their C++ formats, namely@code{// *INDENT-OFF*} and @code{// *INDENT-ON*}.It should be noted that the internal state of @command{indent} remainsunchanged over the course of the unformatted section. Thus, forexample, turning off formatting in the middle of a function andcontinuing it after the end of the function may lead to bizarreresults. It is therefore wise to be somewhat modular in selecting codeto be left unformatted.As a historical note, some earlier versions of @command{indent} producederror messages beginning with @code{*INDENT**}. These versions of@command{indent} were written to ignore any input text lines which beganwith such error messages. I have removed this incestuous feature fromGNU @command{indent}.@node Miscellaneous options, Bugs, Disabling Formatting, Indent Program@comment node-name, next, previous, up@section Miscellaneous options@kindex -versionTo find out what version of @command{indent} you have, use the command@code{indent -version}. This will report the version number of@command{indent}, without doing any of the normal processing.@kindex -v@kindex --verbose@kindex -nv@kindex --no-verbosity@comment Would --terse be better? I think not, but perhaps accepting@comment --no-verbose would avoid error messages.The @option{-v} option can be used to turn on verbose mode. When inverbose mode, @command{indent} reports when it splits one line of inputinto two more more lines of output, and gives some size statistics atcompletion. @kindex -pmt@kindex --preserve-mtime@kindex -npmtThe @option{-pmt} option causes @command{indent} to preserve the accessand modification times on the output files. Using this optionhas the advantage that running indent on all source and headerfiles in a project won't cause @code{make} to rebuild all targets.This option is only available on Operating Systems that have thePOSIX @code{utime(2)} function.@node Bugs, Copyright, Miscellaneous options, Indent Program@comment node-name, next, previous, up@section BugsPlease report any bugs to @email{bug-indent@@gnu.org}.When @command{indent} is run twice on a file, with the same profile,it should @emph{never} change that file the second time. With thecurrent design of @command{indent}, this can not be guaranteed,and it has not been extensively tested.@command{indent} does not understand C. In some cases this leads tothe inability to join lines. The result is that running a filethrough @command{indent} is @emph{irreversible}, even if the used inputfile was the result of running @command{indent} with a given profile(@file{.indent.pro}).While an attempt was made to get @command{indent} working for C++, itwill not do a good job on any C++ source except the very simplest.@command{indent} does not look at the given @option{--line-length} optionwhen writing comments to the output file. This results often in commentsbeing put far to the right. In order to prohibit @command{indent} fromjoining a broken line that has a comment at the end, make sure that thecomments start on the first line of the break.@command{indent} does not count lines and comments (see the @option{-v}option) when @command{indent} is turned off with @code{/* *INDENT-OFF* */}.Comments of the form @code{/*UPPERCASE*/} are not treated as comment but as anidentifier, causing them to be joined with the next line. This renderscomments of this type useless, unless they are embedded in the code tobegin with.@node Copyright, , Bugs, Indent Program@comment node-name, next, previous, up@section CopyrightThe following copyright notice applies to the @command{indent} program.The copyright and copying permissions for this manual appear near thebeginning of @file{indent.texinfo} and @file{indent.info}, and near theend of @file{indent.1}.@displayCopyright @copyright{} 2001 David Ingamells.Copyright @copyright{} 1999 Carlo Wood.Copyright @copyright{} 1995, 1996 Joseph Arceneaux.Copyright @copyright{} 1989, 1992, 1993, 1994, 1995, 1996 Free Software FoundationCopyright @copyright{} 1985 Sun Microsystems, Inc.Copyright @copyright{} 1980 The Regents of the University of California.Copyright @copyright{} 1976 Board of Trustees of the University of Illinois.All rights reserved.Redistribution and use in source and binary forms are permittedprovided that the above copyright notice and this paragraph areduplicated in all such forms and that any documentation,advertising materials, and other materials related to suchdistribution and use acknowledge that the software was developedby the University of California, Berkeley, the University of Illinois,Urbana, and Sun Microsystems, Inc. The name of either Universityor Sun Microsystems may not be used to endorse or promote productsderived from this software without specific prior written permission.THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS ORIMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIEDWARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULARPURPOSE.@end display@c !END THEREST@node Option Summary, Index, Indent Program, Top@appendix Option SummaryHere is a list of all the options for @command{indent}, alphabetized byshort option. It is followed by a cross key alphabetized by long option.@c !BEGIN OPTIONS@c The cross references are all on lines by themselves because this@c looks better in both printed output and Info. 4 Feb 1992 --rjc@table @samp@item -bad@itemx --blank-lines-after-declarationsForce blank lines after the declarations.@*@xref{Blank lines}.@item -bap@itemx --blank-lines-after-proceduresForce blank lines after procedure bodies.@*@xref{Blank lines}.@item -bbb@itemx --blank-lines-before-block-commentsForce blank lines before block comments.@*@xref{Blank lines}.@item -bbo@itemx --break-before-boolean-operatorPrefer to break long lines before boolean operators.@*@xref{Breaking long lines}.@item -bc@itemx --blank-lines-after-commasForce newline after comma in declaration.@*@xref{Declarations}.@item -bl@itemx --braces-after-if-linePut braces on line after @code{if}, etc.@*@xref{Statements}.@item -bli@var{n}@itemx --brace-indent@var{n}Indent braces @var{n} spaces.@*@xref{Statements}.@item -bls@itemx --braces-after-struct-decl-linePut braces on the line after @code{struct} declaration lines.@*@xref{Declarations}.@item -br@itemx --braces-on-if-linePut braces on line with @code{if}, etc.@*@xref{Statements}.@item -brs@itemx --braces-on-struct-decl-linePut braces on @code{struct} declaration line.@*@xref{Declarations}.@item -bs@itemx --Bill-Shannon@itemx --blank-before-sizeofPut a space between @code{sizeof} and its argument.@*@xref{Statements}.@item -c@var{n}@itemx --comment-indentation@var{n}Put comments to the right of code in column @var{n}.@*@xref{Comments}.@item -cbi@var{n}@itemx --case-brace-indentation@var{n}Indent braces after a case label N spaces.@*@xref{Statements}.@item -cd@var{n}@itemx --declaration-comment-column@var{n}Put comments to the right of the declarations in column @var{n}.@*@xref{Comments}.@item -cdb@itemx --comment-delimiters-on-blank-linesPut comment delimiters on blank lines.@*@xref{Comments}.@item -cdw@itemx --cuddle-do-whileCuddle while of @code{do @{@} while;} and preceeding @samp{@}}.@*@xref{Comments}.@item -ce@itemx --cuddle-elseCuddle else and preceeding @samp{@}}.@*@xref{Comments}.@item -ci@var{n}@itemx --continuation-indentation@var{n}Continuation indent of @var{n} spaces.@*@xref{Statements}.@item -cli@var{n}@itemx --case-indentation@var{n}Case label indent of @var{n} spaces.@*@xref{Statements}.@item -cp@var{n}@itemx --else-endif-column@var{n}Put comments to the right of @code{#else} and @code{#endif} statements in column @var{n}.@*@xref{Comments}.@item -cs@itemx --space-after-castPut a space after a cast operator.@*@xref{Statements}.@item -d@var{n}@itemx --line-comments-indentation@var{n}Set indentation of comments not to the right of code to @var{n} spaces.@*@xref{Comments}.@item -bfda@itemx --break-function-decl-argsBreak the line before all arguments in a declaration.@*@xref{Declarations}.@item -bfde@itemx --break-function-decl-argsBreak the line after the last argument in a declaration.@*@xref{Declarations}.@item -di@var{n}@itemx --declaration-indentation@var{n}Put variables in column @var{n}.@*@xref{Declarations}.@item -fc1@itemx --format-first-column-commentsFormat comments in the first column.@*@xref{Comments}.@item -fca@itemx --format-all-commentsDo not disable all formatting of comments.@*@xref{Comments}.@item -gnu@itemx --gnu-styleUse GNU coding style. This is the default.@*@xref{Common styles}.@item -hnl@itemx --honour-newlinesPrefer to break long lines at the position of newlines in the input.@*@xref{Breaking long lines}.@item -i@var{n}@itemx --indent-level@var{n}Set indentation level to @var{n} spaces.@*@xref{Indentation}.@item -ip@var{n}@itemx --parameter-indentation@var{n}Indent parameter types in old-style function definitions by @var{n} spaces.@*@xref{Indentation}.@item -kr@itemx --k-and-r-styleUse Kernighan & Ritchie coding style.@*@xref{Common styles}.@item -l@var{n}@itemx --line-length@var{n}Set maximum line length for non-comment lines to @var{n}.@*@xref{Breaking long lines}.@item -lc@var{n}@itemx --comment-line-length@var{n}Set maximum line length for comment formatting to @var{n}.@*@xref{Comments}.@item -lp@itemx --continue-at-parenthesesLine up continued lines at parentheses.@*@xref{Indentation}.@item -lps@itemx --leave-preprocessor-spaceLeave space between @samp{#} and preprocessor directive.@*@xref{Indentation}.@item -nbad@itemx --no-blank-lines-after-declarationsDo not force blank lines after declarations.@*@xref{Blank lines}.@item -nbap@itemx --no-blank-lines-after-proceduresDo not force blank lines after procedure bodies.@*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -