当前位置:网站首页>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 .
边栏推荐
- 导电滑环磨损快的原因
- [trio basic tutorial 16 from introduction to proficiency] UDP communication test supplement
- General makefile (I) single C language compilation template
- Pointnet++ classification practice
- Matlab2018b problem solving when installing embedded coder support package for stmicroelectronic
- Connection mode - bridge and net
- C language # and #
- How to migrate the device data accessed by the RTSP of the easycvr platform to easynvr?
- Correlation based template matching based on Halcon learning [II] find_ ncc_ model_ defocused_ precision. hdev
- The browser cannot access Baidu
猜你喜欢

Ads learning record (lna_atf54143)

My-basic application 2: my-basic installation and operation
![Halcon's practice based on shape template matching [2]](/img/70/3e905661785e570fb406b8e97d41e6.jpg)
Halcon's practice based on shape template matching [2]

MySQL blind note common functions

生产中影响滑环质量的因素

STM32 tutorial triple ADC interleaved sampling
![[trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code](/img/58/576b6b77509ed7a9bef138f3899e37.jpg)
[trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code

Basic embedded concepts

Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)

Arduino uses nrf24l01+ communication
随机推荐
VESC Benjamin test motor parameters
[trio basic from introduction to mastery tutorial XIV] trio realizes unit axis multi-color code capture
Drive LED -- GPIO control
Explain task scheduling based on Cortex-M3 in detail (Part 1)
C WinForm [view status bar -- statusstrip] - Practice 2
L'étude a révélé que le système de service à la clientèle du commerce électronique transfrontalier a ces cinq fonctions!
Can't find real-time chat software? Recommend to you what e-commerce enterprises are using!
My-basic application 2: my-basic installation and operation
1-stm32 operation environment construction
Soem EtherCAT source code analysis I (data type definition)
Imx6ull bare metal development learning 1-assembly lit LED
[untitled] record the visual shock of the Winter Olympics and the introduction of the display screen
IC software learning
How to select conductive slip ring
H264 (I) i/p/b frame gop/idr/ and other parameters
Altium designer 19.1.18 - change the transparency of copper laying
Design a clock frequency division circuit that can be switched arbitrarily
【云原生 | 从零开始学Kubernetes】三、Kubernetes集群管理工具kubectl
[trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code
Volatile of C language