乐清网站优化推广,画江湖网站开发文档,北京做网站的大公司有哪些,帮别人做网站服务器indent是linux下一个能力极强的代码整理软件#xff0c;使用他#xff0c;可以轻松的写出代码风格十分精良的代码。但是indent的参数太多#xff0c;使用起来不是很容易#xff0c;怎么办呢#xff1f;查看/usr/src/linux-headers-/scripts/Lindent文件 #xff0c;可以看…indent是linux下一个能力极强的代码整理软件使用他可以轻松的写出代码风格十分精良的代码。但是indent的参数太多使用起来不是很容易怎么办呢查看/usr/src/linux-headers-/scripts/Lindent文件 可以看到一行代码:indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs-cp1这一行就是linux内核使用indent整理代码的格式使用这条命令就可以实现风格十分良好的C或C代码其中-l80是每一行最多80个字母超出会拆行如果不喜欢可以使用更长的行字数使用的indent参数 值 含义--blank-lines-after-declarations bad 变量声明后加空行--blank-lines-after-procedures bap 函数结束后加空行--blank-lines-before-block-comments bbb 块注释前加空行--break-before-boolean-operator bbo 较长的行在逻辑运算符前分行--blank-lines-after-commas nbc 变量声明中逗号分隔的变量不分行--braces-after-if-line bl if和{分做两行--brace-indent 0 bli0 {不继续缩进--braces-after-struct-decl-line bls 定义结构struct和{分行--comment-indentationn c33 语句后注释开始于行33--declaration-comment-columnn cd33 变量声明后注释开始于行33--comment-delimiters-on-blank-lines ncdb 不将单行注释变为块注释--cuddle-do-while ncdw do ---while的while和其前面的}另起一行--cuddle-else nce else和其前面的}另起一行--case-indentation 0 cli0 switch中的case语句所进0个空格--else-endif-columnn cp33 #else, #endif后面的注释开始于行33--space-after-cast cs 在类型转换后面加空格--line-comments-indentation n d0 单行注释(不从1列开始的)不向左缩进--break-function-decl-args nbfda 关闭函数的参数一个一行--declaration-indentationn di2 变量声明变量开始于2行即不必对齐--format-first-column-comments nfc1 不格式化起于第一行的注释--format-all-comments nfca 不开启全部格式化注释的开关--honour-newlines hnl Prefer tobreak long lines at the position of newlines in the input.--indent-leveln i4 设置缩进多少字符如果为tab的整数倍用tab来缩进否则用空格填充。--parameter-indentationn ip5 旧风格的函数定义中参数说明缩进5个空格--line-length 75 l75 非注释行最长75--continue-at-parentheses lp 续行从上一行出现的括号开始--space-after-procedure-calls pcs 函数和(之间插入一个空格--space-after-parentheses nprs 在(后)前不插入空格--procnames-start-lines psl 将函数名和返回类型放在两行定义--space-after-for saf for后面有空格--space-after-if sai if后面有空格--space-after-while saw while后面有空格--start-left-side-of-comments nsc 不在生成的块注释中加*--swallow-optional-blank-lines nsob 不去掉可添加的空行--space-special-semicolon nss 一行的for或while语句在;前不加空。--tab-size ts4 一个tab为4个空格(要能整除-in)--use-tabs ut 使用tab来缩进【转贴】用indent 进行代码格式化2009-03-27 12:01indent常用的参数设置以前的用法indent-kr -cli4 -i4 -nut改进的用法indent-kr -cli4 -nut -bl4 -bli0注释-kr, UseKernighan Ritchie coding style.-cli4,specifies the number of spaces that case labels should be indentedto the right of the containing switch statement.-nut,不使用空格。-bl4,大括号内的缩进这里为4个空格。-bli0,“if”语句后大括号的缩进一般设为“0”。indent工具参数indent是一个常用的Linux的C代码格式化工具,但是参数太多,很难记忆,目前发现一组参数,可以格式化为我常用的代码格式。-bad -bap-bbb -bbo -nbc -bl -bli0 -bls -c33 -cd33 -ncdb -ncdw -nce -cli0-cp33 -cs -d0 -nbfda-nfc1-nfca -hnl -ip5 -l75 -lp -pcs -nprs -saf -sai -saw -nsc -nsob -nss-i4 -ts4 -ut保存在~/.indent.pro就是默认的indent参数了。3.5. 用 indent进行代码格式化一个范例胜过前言万语。用 indent 格式化代码再从格式化前后的格式变化 来学习格式化规范。可以用不同的参数调用 indent3.5.1. introduce indentWhat is IndentThe indent program can be used to make code easier to read. Itcan also convert from one style. of writing C to another.DownloadCurrent Version: GNU indent 2.2.7。 Download:3.5.2. Indent参数规范我们参照GNUKernighan RitchieBerkeley风格制定了自己风格indent命令参数-bad -bap -bbb -bbo -nbc -bl -bli0 -bls -c33 -cd33 -ncdb -ncdw -nce-cli0 -cp33 -cs -d0 -nbfda -di2 -nfc1 -nfca -hnl -ip5 -l75 -lp -pcs-nprs -psl -saf -sai -saw -nsc -nsob -nss -i4 -ts4 -utindent配置文件如上参数可写入用户目录下的文件.indent.pro作为运行indent的确 省参数。indent配置说明表 1.Indent代码格式化说明使用的indent参数值含义--blank-lines-after-declarationsbad变量声明后加空行--blank-lines-after-proceduresbap函数结束后加空行--blank-lines-before-block-commentsbbb块注释前加空行--break-before-boolean-operatorbbo较长的行在逻辑运算符前分行--blank-lines-after-commasnbc变量声明中逗号分隔的变量不分行--braces-after-if-lineblif和{分做两行--brace-indent 0bli0{不继续缩进--braces-after-struct-decl-linebls定义结构struct和{分行--comment-indentationnc33语句后注释开始于行33--declaration-comment-columnncd33变量声明后注释开始于行33--comment-delimiters-on-blank-linesncdb不将单行注释变为块注释--cuddle-do-whilencdwdo --- while的while和其前面的}另起一行--cuddle-elsenceelse和其前面的} 另起一行--case-indentation 0cli0switch中的case语句所进0个空格--else-endif-columnncp33#else, #endif后面的注释开始于行33--space-after-castcs在类型转换后面加空格--line-comments-indentation nd0单行注释(不从1列开始的)不向左缩进--break-function-decl-argsnbfda关闭函数的参数一个一行--declaration-indentationndi2变量声明变量开始于2行即不必对齐--format-first-column-commentsnfc1不格式化起于第一行的注释--format-all-commentsnfca不开启全部格式化注释的开关--honour-newlineshnlPrefer to break long lines at the position of newlines in theinput.--indent-levelni4设置缩进多少字符如果为tab的整数倍用tab来缩进否则用 空格填充。--parameter-indentationnip5旧风格的函数定义中参数说明缩进5个空格--line-length 75l75非注释行最长75--continue-at-parentheseslp续行从上一行出现的括号开始--space-after-procedure-callspcs函数和(之间插入一个空格--space-after-parenthesesnprs在(后)前不插入空格--procnames-start-linespsl将函数名和返回类型放在两行定义--space-after-forsaffor后面有空格--space-after-ifsaiif后面有空格--space-after-whilesawwhile后面有空格--start-left-side-of-commentsnsc不在生成的块注释中加*--swallow-optional-blank-linesnsob不去掉可添加的空行--space-special-semicolonnss一行的for或while语句在;前不加空。--tab-sizets4一个tab为4个空格(要能整除-in)--use-tabsut使用tab来缩进