当前位置:网站首页>Use indent to format code
Use indent to format code
2022-07-05 08:05:00 【Car chezi】
This is a paragraph Linux Tools on . download indent Omit .
For example, to xxx.c format , I used to indent -npro -kr -i4 -ts4 -sob -l80 -ss -ncs -cp1 -br -nce -nut xxx.c -o xxx1.c
see /usr/src/linux-headers-< edition >/scripts/Lindent
file , You can see a line of code :
indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1
This line is linux The kernel using indent Tools organize the format of the code .
I used to add -br -nce -nut
What do these parameters mean ?
| Options | explain |
|---|---|
| -npro | Don't read indent Configuration file for :.indent.pro |
| -kr | Specify the use of Kernighan&Ritchie The format of . It can be replaced by -orig,BSD style |
| -i8 | Set the number of indented cells to 8, You can modify |
| -ts8 | Set up tab by 8 A space , You can modify |
| -sob | Delete extra blank lines |
| -l80 | Each line of code is longer than 80 Line break ( For non comment lines ) |
| -ss | if for perhaps while When the section has only one line , Put a space before the semicolon |
| -ncs | no-space-after-casts, Not in cast And then it's empty |
| -cp1 | #else、#endif The following comments start with the column 1( There is a blank space in front ) |
| -nut | Don't use tab Indent , namely tab Replace... With a space |
| -br | if、while Wait for the parentheses and if、while On the same line .Put braces on line with if, etc. |
-nce and -ce What's the difference ?
-ce, --cuddle-else, Cuddle( The meaning of hugging ) else and preceding ‘}’.
for instance , If you use -br -ce, The resulting format is
if (x > 0) {
x--;
} else {
fprintf (stderr, "...something wrong?\n");
}
Did you see? ? else By } and { Surround
If you use -br -nce, The resulting format is
if (x > 0) {
x--;
}
else {
fprintf (stderr, "...something wrong?\n");
}
In fact, that is else Another line .
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:
-nbad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0
-cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 -lp -npcs
-nprs -npsl -saf -sai -saw -nsc -nsob -nss
I won't explain it one by one . use man Command to check .
边栏推荐
- Semiconductor devices (III) FET
- Connection mode - bridge and net
- [professional literacy] specific direction of analog integrated circuits
- Cadence simulation encountered "input.scs": can not open input file change path problem
- [tutorial 15 of trio basic from introduction to proficiency] trio free serial communication
- Altium designer 19.1.18 - change the transparency of copper laying
- Shape template matching based on Halcon learning [9] PM_ multiple_ dxf_ models. Hdev routine -- [read and write XLD from DXF file]
- Global and Chinese market of urban rail connectors 2022-2028: Research Report on technology, participants, trends, market size and share
- Halcon's practice based on shape template matching [1]
- IC software learning
猜你喜欢

Matlab2018b problem solving when installing embedded coder support package for stmicroelectronic

Drive LED -- GPIO control

Train your dataset with yolov4

Software designer: 03 database system

Altium designer 19.1.18 - Import frame

Arduino uses nrf24l01+ communication

UEFI development learning 5 - simple use of protocol

UEFI development learning 6 - creation of protocol
![[trio basic tutorial 18 from introduction to proficiency] trio motion controller UDP fast exchange data communication](/img/05/0f63e4cd3da24e5b956ec5899b939d.jpg)
[trio basic tutorial 18 from introduction to proficiency] trio motion controller UDP fast exchange data communication

Improve lighting C program
随机推荐
Altium designer 19.1.18 - hide the fly line of a network
VESC Benjamin test motor parameters
【云原生 | 从零开始学Kubernetes】三、Kubernetes集群管理工具kubectl
Shape template matching based on Halcon learning [viii] PM_ multiple_ models. Hdev routine
Global and Chinese market of urban rail connectors 2022-2028: Research Report on technology, participants, trends, market size and share
2021-10-28
UEFI development learning 3 - create UEFI program
Record the opening ceremony of Beijing Winter Olympics with display equipment
Measurement fitting based on Halcon learning [II] meaure_ pin. Hdev routine
Makefile application
Network communication model -- Network OSI tcp/ip layering
UEFI development learning 5 - simple use of protocol
C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,LU分解(LU Decomposition)源程序
How to migrate the device data accessed by the RTSP of the easycvr platform to easynvr?
L'étude a révélé que le système de service à la clientèle du commerce électronique transfrontalier a ces cinq fonctions!
Global and Chinese market of resistivity meter 2022-2028: Research Report on technology, participants, trends, market size and share
Altium designer 19.1.18 - Import frame
Soem EtherCAT source code analysis II (list of known configuration information)
Can't find real-time chat software? Recommend to you what e-commerce enterprises are using!
Drive LED -- GPIO control