工具及方法 - 在Source Insight中使用代码格式化工具
在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 |
有个缺点是,不能对文件进行批量修改,凑活用了。
工具及方法 - 在Source Insight中使用代码格式化工具相关推荐
- 在source insight 中添加系统字体
在source insight 中添加系统字体 1. "控制面板:--->"字体"--->找到Courier New(建议用这个字体,比Courier要平滑) ...
- 解决 Source Insight中的parse too complex问题
FROM:http://blog.csdn.net/kunbo_1399614213/article/details/46730049 Source Insight 在导入文件后,有个别的文件无法正常 ...
- 【editor】Source Insight定制之代码风格自动校准功能(AStyle的使用)
前一篇博文讲了Source Insight编辑器中简单的宏命令(Macro)的制作方式,并与快捷键关联起来.只是为了解决代码的风格和快捷键注释的问题.但从目前来看,只有代码的快捷注释功能是有实用价值的 ...
- 用Handler的post()方法来传递线程中的代码段到主线程中执行
自定义的线程中是不能更新UI的,但是如果遇到更新UI的事情,我们可以用handler的post()方法来将更新UI的方法体,直接传送到主线程中,这样就能直接更新UI了.Handler的post()方法 ...
- Source Insight中Quicker.em的使用方法
1.安装方法 Source Insight有很多宏可以用,这里介绍的宏是quicker.em这个宏,它是华为的一个员工写的,很实用. 1)安装quicker.em宏 一.打开base这个工程Proje ...
- Source Insight中显示函数调用关系的方法
接上一篇博客,解决了中文注释乱码后,使用Source Insight显示函数调用关系树状图 网上借鉴了一些经验,但感觉可能是版本不同未能完全奏效,下面我将记录我最终探寻出的解决方法 1.双击编辑器中需 ...
- ubuntu14.04中 gedit 凝视能显示中文,而source insight中显示为乱码的解决的方法
1.乱码显示情况: 2.用gedit打开文件,并用ctrl+shift+s(另存为),当中charactor coding选为chinese simplified(GB2312); 2.改动个文件名称 ...
- Source Insight中的多行注释
我们经常要对一整段代码进行注释,很多代码编辑器都提供了这样的功能:用快捷键"Ctrl + /"来实现"//"的多行注释. 但是在用source insight的 ...
- 将Source Insight里面着色代码拷贝到word里面的方法
1.用Source Insight打开文件后,File->Print: 2.在 常规->选择打印机中,选择"Adobe PDF"(或者其他pdf打印机): 3.点确定, ...
最新文章
- Java程序设计学习笔记(一)
- TalkingData CTO肖文峰:研发工程师,你为啥升不上去?
- 方法 手写promise_高级前端养成37js专精06之手写promise(上)
- Android httpUrlConnection的基本使用
- 初识Mysql(part19)--我需要知道的3条Mysql语句之组合查询
- 年薪28万 ~60万+,北理工计算机学院可视媒体计算团队诚招博士后
- 将jpg文件当作php文件来解析,解析漏洞
- static变量和static函数的用法摘抄
- SQL Server存储过程中使用表值作为输入参数示例
- android——根据MVC框架设计的结构
- 百度联合清华发布国内首个基于AI实践的产业智能化白皮书
- 使用python定义量化指标公式
- 详解傅里叶变换与拉普拉斯,Z变化的联系
- 实例分割最全综述(上):二阶段实例分割和一阶段实例分割
- 虚拟机批量克隆工具_如何使用老毛桃winpe进行克隆磁盘?
- 【Java】实现多线程计算阶乘(完整版)
- 常见Web安全漏洞深入解析
- python给excel排序_Python实现EXCEL表格的排序功能示例
- 分布式事务seata整合nacos+openfeign
- 选择某种Map集合保存学号从1到15的学员的学号(键)和姓名(值)