Code format of code blocks
AStyle 是 Code::Blocks 的默认代码格式化工具,默认的 Allman (ANSI) 对于我习惯 Java 的样式来说很不习惯,但没关系,还可以配置多种格式。
0. 样式选择
0. 样式选择
Setting -> Editor -> Source formatter
我选择了 Google 的样式
1. 格式化整个工程
1. 格式化整个工程
右键到工程上,选 Format this project (AStyle)
2. 格式化单个文件
2. 格式化单个文件
2.1. 在 Workspace 的目录树中操作
在 Workspace 的目录树中右键单击文件名,选 Format this file (AStyle)
2.2. 在编辑区中操作
或在编辑区点右键,选 Format use AStyle
2.3. 通过菜单操作
Plugins -> Source code formatter
2.4. 设置快捷键
Settings -> Editor -> Keyboard shortcuts -> Plugins -> Source code formatter (AStyle)
我这里设置了在 IntelliJ IDEA 中常用的 Ctrl-Alt-L 组合键。