当前位置:网站首页>工具及方法 - 在Source Insight中使用代码格式化工具
工具及方法 - 在Source Insight中使用代码格式化工具
2022-06-24 09:58:00 【夜流冰】
在Source Insight 4.0中,有代码格式化工具:

当你打开某个源文件后,可以对当前文件进行格式修改:

有ANSI、GNU、K&R三种编码风格可以选择。

也可以自己进行设置:

同时,这个代码格式设置还支持导入导出,使用XML文件。
另外在帮助文档里,可以搜到相关的使用说明。

相关说明
1,这里支持的文件类型是C/C++, C#, Java,这些使用类似花括号的语法。
2,你可以将修改后的设置保存成自己的编码格式。
3,如果选择一段代码,则只对选中代码进行格式化。如果不选择代码仅保留一个插入符,则对当前文件进行格式化。
相关设置
Layout and Flow
Control Statements - if, while, for, etc. | Control statements sart a new line | yes |
Blank line before control statement | yes | |
Blank line after control statements | yes | |
Keep else-if on same line | yes | |
Force single line bodies onto next line | yes | |
Add braces around single statement bodies | no | |
Space after keywords: if, while, for, etc. | yes | |
Brace style | Open { brace on new line | no |
Indent the open { brace | no | |
Indent the close { brace | no | |
Extra indent of statements inside braces | no | |
Outermost braces at column 1 | yes | |
Keep } else on same line | no | |
Indentation | Convert spaces to tabs | no |
Indent width | 4 | |
Indentation for Goto labels | At leftmost column | yes |
Blank line above labels | yes |
Classes and Comments
Classes and Structs | Indent members | yes |
Blank line above public/private labels | yes | |
Blank line below public/private labels | yes | |
Align field members at column | 16 | |
Align bit-field sizes at column | 32 | |
Indentation for Member Access Specifiers( private/public/etc) | One indent level less than other declarations | yes |
Comments | Preserve blank lines in comments | yes |
Blank line above comment blocks | yes | |
Preserve text formatting in lines that contain only comments | yes | |
Align right-hand comments at column | 60 | |
Other | Indent namespace contents | no |
Spacing
Line Width | Wrap lines at column | 120 |
Preprocessor Macros(#defines) | Align macro names at column | 8 |
Align macro values at column | 40 | |
Align macro continuation(\) at column | 80 | |
Line Spacing | Preserve blank lines in source | no |
Blank lines between functions. | 2 | |
White space | Space between function name and parenthese | no |
Space between function parameters | yes | |
Spaces around operators | yes | |
Spaces inside prentheses like ‘( this )’ | no | |
Remove extra white space at end of lines | yes | |
Align variables at column: | 16 | |
Align assignments at column: | 20 |
布局和控制流
控制语句 | 控制语句新起一行 | yes |
控制语句前空一行 | yes | |
控制语句后空一行 | yes | |
else if 语句在同一行 | yes | |
执行语句只有一条时单起一行 | yes | |
执行语句只有一条时是否加大括号 | no | |
if, while, for和后面括号间是否加空格 | yes | |
空格风格 | 开括号新起一行 | no |
开括号缩进 | no | |
关括号缩进 | no | |
括号内语句缩进 | no | |
最外层括号都在第一列 | yes | |
} else放在同一行 | no | |
缩进 | 将空格转换为Tab键 | no |
缩进宽度 | 4 | |
Goto语句的标签 | 在最左侧 | yes |
标签前空一行 | yes |
类和注释
类和结构体 | 类成员缩进 | yes |
public等访问控制符前加空行 | yes | |
public等访问控制符后加空行 | yes | |
成员变量名对齐的列 | 16 | |
位域成员变量对齐的列 | 32 | |
访问控制符的缩进 | 比其他声明缩进一级 | yes |
注释 | 保留注释中的空行 | yes |
注释块前加空行 | yes | |
保留注释中的原本格式 | yes | |
右侧行尾注释对齐的列 | 60 | |
其他 | 名称空间的内容缩进 | no |
空白
每行宽度 | 在哪一列换行 | 120 |
预处理 | 预处理名字对齐的列 | 8 |
预处理的值对齐的列 | 40 | |
预处理行连接符对齐的列 | 80 | |
空行 | 是否保留源码中多余的空行 | no |
两个函数之间的空行个数 | 2 | |
空格 | 函数名和后面括号之间是否加空格 | no |
函数参数间的空格 | yes | |
二元操作符两侧是否有空格 | yes | |
括号内部是否加空格,比如( this ) | no | |
删除行尾多余的空格 | yes | |
变量声明时,变量名对齐的列 | 16 | |
变量赋值符号对齐的列 | 20 |
有个缺点是,不能对文件进行批量修改,凑活用了。
边栏推荐
- Internship experience sharing in ByteDance 𞓜 ten thousand word job guide
- Simple pricelist style code
- [Flink source code practice (I)] add a rest API to Flink
- Centripetalnet: more reasonable corner matching, improved cornernet | CVPR 2020 in many aspects
- [net action!] Cos data escort helps SMEs avoid content security risks!
- What characteristics should a good design website have?
- Qt: 判断字符串是否为数字格式
- Give you a server. Can you deploy your code online?
- Common third-party UI frameworks
- TP-LINK 1208路由器教程(2)
猜你喜欢

First acquaintance with string+ simple usage (I)

SQL Server about like operator (including the problem of field data automatically filling in spaces)

TP-LINK 1208路由器教程(2)

历史上的今天:图灵诞生日;互联网奠基人出生;Reddit 上线

2D 照片变身 3D 模型,来看英伟达的 AI 新“魔法”!

Maui's way of learning -- Opening
![[IEEE publication] International Conference on natural language processing and information retrieval in 2022 (ecnlpir 2022)](/img/d6/8c20944ce354c9619a61a73f2c72b1.png)
[IEEE publication] International Conference on natural language processing and information retrieval in 2022 (ecnlpir 2022)

PHP短信通知+语音播报自动双呼

@Requestbody annotation

"One good programmer is worth five ordinary programmers!"
随机推荐
Shell脚本(.sh文件)如何执行完毕之后不自动关闭、闪退?
数组怎么转对象,对象怎么转数组
Tencent wetest platform will bring new benefits in 2021 with 618 special offers!
Introduction to the use of splice() method
Differences among cookies, session, localstorage and sessionstorage
Five methods of JS array summation
Moving Tencent to the cloud cured their technical anxiety
Four methods of object merging and four methods of object merging in JS
Today in history: Turing's birth day; The birth of the founder of the Internet; Reddit goes online
08. Tencent cloud IOT device side learning - device shadow and attributes
The latest entry date of SQL Sever test questions
How to convert an array to an object, and how to convert an object to an array
Dedecms template file explanation and homepage label replacement
Remote desktop copy paste exception
把騰訊搬到雲上,治愈了他們的技術焦慮
[technical tutorial] national standard protocol platform easygbs cascading supports customized national standard channels
What are the means of network promotion?
Déplacer Tencent sur le cloud a guéri leur anxiété technologique
"Adobe international certification" Adobe Photoshop adjusts cropping, rotation and canvas size
Go basic series | 4 Environment construction (Supplement) - gomod doubts