当前位置:网站首页>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 .
边栏推荐
- OLED 0.96 inch test
- C WinForm [get file path -- traverse folder pictures] - practical exercise 6
- How to excavate and research ideas from the paper
- General makefile (I) single C language compilation template
- My-basic application 1: introduction to my-basic parser
- Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine
- Global and Chinese markets for recycled boilers 2022-2028: Research Report on technology, participants, trends, market size and share
- [trio basic from introduction to mastery tutorial XIV] trio realizes unit axis multi-color code capture
- Nb-iot technical summary
- Some tips for using source insight (solve the problem of selecting all)
猜你喜欢

Communication standard -- communication protocol

My-basic application 2: my-basic installation and operation

Step motor generates S-curve upper computer

Embedded composition and route

Altium designer learning (I)

Beijing Winter Olympics opening ceremony display equipment record 3

Compilation warning solution sorting in Quartus II

Altium designer 19.1.18 - Import frame

PMSM dead time compensation

Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)
随机推荐
Global and Chinese markets for flexible endoscopic lithotripsy devices 2022-2028: Research Report on technology, participants, trends, market size and share
C, Numerical Recipes in C, solution of linear algebraic equations, LU decomposition source program
Factors affecting the quality of slip rings in production
Global and Chinese markets of large aperture scintillators 2022-2028: Research Report on technology, participants, trends, market size and share
Measurement fitting based on Halcon learning [II] meaure_ pin. Hdev routine
Semiconductor devices (I) PN junction
[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication
Bootloader implementation of PIC MCU
C WinForm [realize the previous and next selection pictures] - practice 7
Define in and define out
My-basic application 1: introduction to my-basic parser
Reasons for rapid wear of conductive slip rings
Record the torch encountered by win10 cuda. is_ False problem in available()
Altium designer 19.1.18 - change the transparency of copper laying
Gradle复合构建
Matlab2018b problem solving when installing embedded coder support package for stmicroelectronic
Global and Chinese markets for recycled boilers 2022-2028: Research Report on technology, participants, trends, market size and share
C language # and #
VESC Benjamin test motor parameters
[tutorial 19 of trio basic from introduction to proficiency] detailed introduction of trio as a slave station connecting to the third-party bus (anybus PROFIBUS DP...)