当前位置:网站首页>工具及方法 - 在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 |
有个缺点是,不能对文件进行批量修改,凑活用了。
边栏推荐
- Extremenet: target detection through poles, more detailed target area | CVPR 2019
- Base64 decoding method three ways for non professionals
- Why should we make the best use of the external chain in SEO?
- Act as you like
- What is recursion?
- Go basic series | 4 Environment construction (Supplement) - gomod doubts
- “一个优秀程序员可抵五个普通程序员!”
- The latest entry date of SQL Sever test questions
- Qt: 判断字符串是否为数字格式
- Suddenly I thought of the wooden house in my hometown
猜你喜欢

Maui's way of learning -- Opening

Maui的学习之路 -- 开篇

Beauty of script │ VBS introduction interactive practice

喜歡就去行動

Visual presentation of pictures effectively enhances the attraction of large screen

图片的可视化呈现有效增强大屏吸引力

Today in history: Turing's birth day; The birth of the founder of the Internet; Reddit goes online

【毕业季·进击的技术er】绕树三匝,何枝可依?

计组_cpu的结构和工作流程

把騰訊搬到雲上,治愈了他們的技術焦慮
随机推荐
Shape change loader loads jsjs special effect code
How to use data analysis tools to deal with emergencies in retail industry
[IEEE publication] International Conference on natural language processing and information retrieval in 2022 (ecnlpir 2022)
数组怎么转对象,对象怎么转数组
SwiftUI Swift 内功之 Swift 中的属性观察者 didSet 与 willSet
PHP短信通知+语音播报自动双呼
[深度学习][pytorch][原创]crnn在高版本pytorch上训练loss为nan解决办法
Svg+js drag slider round progress bar
"Write once, run at all ends", Qualcomm released AI software stack!
How does easydss use go fastdfs distributed file servers to reduce service pressure?
@Requestbody annotation
齐次坐标的理解
How to use arbitrarygen code generator what are the characteristics of this generator
如何只导出word文档中的标题?(即将正文内容都删除,只保留标题)B站牛逼
Apple's legendary design team disbanded after jobs refused to obey cook
Give you a server. Can you deploy your code online?
What is recursion?
Network monitoring: active troubleshooting becomes simple
[the lottery in May has ended, and the list of winners has been announced] special session of techo youth university open course database
What is the bin file for? How to open the file correctly