linux kernel有一个脚本Lindent,可以帮助你将自己的代码做一个好的代码风格格式化。 常用的设置: (这个风格我喜欢) 参数说明: 我较常用的是: indent -npro -nip -nlp -npsl -i4 -ts4 -sob -l200 -ss -bl -bli 0 代码文件名
alias myindent='indent -npro -kr -bl -nce -bli0 -i2 -ts2 -sob -l80 -nfc1 -ss -ncs' Common stylesThere are several common styles of C code, including the GNU style, the Kernighan & Ritchie style, and the original Berkeley style. A style may be selected with a single background option, which specifies a set of values for all other options. However, explicitly specified options always override options implied by a background option.
As of version 1.2, the default style of GNU
The GNU coding style is that preferred by the GNU project. It is the style that the GNU Emacs C mode encourages and which is used in the C portions of GNU Emacs. (People interested in writing programs for Project GNU should get a copy of The GNU Coding Standards, which also covers semantic and portability issues such as memory usage, the size of integers, etc.)
The Kernighan & Ritchie style is used throughout their well-known book The C Programming Language. It is enabled with the ‘-kr’ option. The Kernighan & Ritchie style corresponds to the following set of options:
Kernighan & Ritchie style does not put comments to the right of code in the same column at all times (nor does it use only one space to the right of the code), so for this style
The style of the original Berkeley
The Linux style is used in the linux kernel code and drivers. Code generally has to follow the Linux coding style to be accepted. This style is equivalent to the following settings:
表 1. Indent代码格式化说明
|
相关文章
- Linux 代码格式化工具 indent
- python 代码格式化工具:YAPF
- CoolFormat源代码格式化工具
- 代码格式化工具 Astyle
- 用JAVA写了一个简单的JS代码格式化工具
- 代码格式化工具---prettier配置
- MyEclipse工具开发常用快捷键 普通: Ctrl+Shift+L 显示所有快捷键 Ctrl+K 参照选中的词(Word)快速定位到下一个 Ctrl+Shift+K 参照选中的词(Word)快速定位到上一个 Ctrl+O 快速显示OutLine Ctrl+T 快速显示当前类的继承结构 Ctrl+Shift+X 把选中文本全部改为大写 Ctrl+Shift+Y 把选中文本全部改为小写 Ctrl+Shift+F 按照当前的配置文件格式化源代码 Ctrl+L 弹出行定位框以便定位到某一行 Ctrl+Numpad_Divide Ctrl+/(小键盘) 使代码折叠可用 Ctrl+Numpad_Multify Ctrl+*(小键盘) 展开当前类中的所有代码 Ctrl+Shift+Numpad_Divide Ctrl+Shift+/(小键盘) 折叠所有,如果不能全部成功折叠,将光标移到文档最后试着或多按几次折叠当前类中的所有代码 Ctrl+1 快速修正,需要导包的时候出现导包提示界面, Ctrl+Q 定位到
- 适用于Linux和/或MonoDevelop的C#代码格式化程序
- astyle代码格式化工具
- 代码格式化工具:AStyle和CoolFormat