辅助开发: Keil中使用Aystyle 快速格式化所有代码
辅助开发: Keil中使用Aystyle 快速格式化所有代码
- 开始
- 添加菜单到KEIL
- 我使用的参数
- 部分参数定义参考
- 官方参数参考
- Usage:
- Options:
- Option Files:
- Disable Formatting:
- Brace Style Options:
- Tab Options:
- Brace Modify Options:
- Indentation Options:
- Padding Options:
- Formatting Options:
- Objective-C Options:
- Other Options:
- Command Line Only:
开始
此前是在Source Insight 中添加Aystle来格式化代码的,先要打开SI然后再运行快捷键来格式化代码,没有找到一键格式化全部文件的办法,一个个文件格式化相当麻烦,等待时间也长。今天搜索一下,发现可以直接在Keil中实现,参考链接:
https://blog.csdn.net/u010160335/article/details/78587411
注意,格式化所有文件前,先要在Keil打开其中一个待格式化的文件,然后才会自动格式化该文件同目录下的所有文件。
添加菜单到KEIL
添加“格式化所有文件”菜单
添加“格式化当前文件”菜单
我使用的参数
–style=ansi -c -D -d -H -j -M -n -p -s4 -w -S
部分参数定义参考
-a 大括号保留在上一行
-c tab转空格
-D 括号内侧插入空格
-d 只在括号外面插入空格,
-F 空行分隔无关块
-H 是’if’, ‘for’, 'while’等关键字右边留空格;
-l 处理定义和函数中的大括号
-j 单行if会自动加入大括号
-K 缩进case下面的语句
-M 是缩进函数多个参数放在不同行的情况,这个说不清楚,得放个代码示例:
-n 不生成备份文件,即默认的 .orig文件。
-p 在操作符两边插入空格,如=、+、-等。
-s4 行缩进用4个空格
-S switch 与case不同列,case缩进
-U 是移除括号里外的空格;
-w 格式化多行的宏定义
-x 删除多余空行
官方参数参考
#-----------------------------------------------------------------------------------------------------------
Artistic Style 3.1
Maintained by: Jim Pattee
Original Author: Tal Davidson
Usage:
astyle [OPTIONS] File1 File2 File3 [...]astyle [OPTIONS] < Original > BeautifiedWhen indenting a specific file, the resulting indented file RETAINS
the original file-name. The original pre-indented file is renamed,
with a suffix of '.orig' added to the original filename.Wildcards (* and ?) may be used in the filename.
A 'recursive' option can process directories recursively.
Multiple file extensions may be separated by a comma.By default, astyle is set up to indent with four spaces per indent,
a maximal indentation of 40 spaces inside continuous statements,
a minimum indentation of eight spaces inside conditional statements,
and NO formatting options.
Options:
This program follows the usual GNU command line syntax.
Long options (starting with '--') must be written one at a time.
Short options (starting with '-') may be appended together.
Thus, -bps4 is the same as -b -p -s4.
Option Files:
Artistic Style looks for a default option file and/or a project
option file in the following order:
1. The command line options have precedence.
2. The project option file has precedence over the default fileo the file name indicated by the --project= command line option.o the file named .astylerc or _ astylerc.o the file name identified by ARTISTIC_STYLE_PROJECT_OPTIONS.o the file is disabled by --project=none on the command line.
3. The default option file that can be used for all projects.o the file path indicated by the --options= command line option.o the file path indicated by ARTISTIC_STYLE_OPTIONS.o the file named .astylerc in the HOME directory (for Linux).o the file name astylerc in the APPDATA directory (for Windows).o the file is disabled by --project=none on the command line.
Long options within the option files may be written without '--'.
Line-end comments begin with a '#'.
Disable Formatting:
Disable Block
Blocks of code can be disabled with the comment tags *INDENT-OFF*
and *INDENT-ON*. It must be contained in a one-line comment.Disable Line
Padding of operators can be disabled on a single line using the
comment tag *NOPAD*. It must be contained in a line-end comment.
Brace Style Options:
default brace style
If no brace style is requested, the opening braces will not be
changed and closing braces will be broken from the preceding line.--style=allman OR --style=bsd OR --style=break OR -A1
Allman style formatting/indenting.
Broken braces.--style=java OR --style=attach OR -A2
Java style formatting/indenting.
Attached braces.--style=kr OR --style=k&r OR --style=k/r OR -A3
Kernighan & Ritchie style formatting/indenting.
Linux braces.--style=stroustrup OR -A4
Stroustrup style formatting/indenting.
Linux braces.--style=whitesmith OR -A5
Whitesmith style formatting/indenting.
Broken, indented braces.
Indented class blocks and switch blocks.--style=vtk OR -A15
VTK style formatting/indenting.
Broken, indented braces except for the opening braces.--style=ratliff OR --style=banner OR -A6
Ratliff style formatting/indenting.
Attached, indented braces.--style=gnu OR -A7
GNU style formatting/indenting.
Broken braces, indented blocks.--style=linux OR --style=knf OR -A8
Linux style formatting/indenting.
Linux braces, minimum conditional indent is one-half indent.--style=horstmann OR --style=run-in OR -A9
Horstmann style formatting/indenting.
Run-in braces, indented switches.--style=1tbs OR --style=otbs OR -A10
One True Brace Style formatting/indenting.
Linux braces, add braces to all conditionals.--style=google OR -A14
Google style formatting/indenting.
Attached braces, indented class modifiers.--style=mozilla OR -A16
Mozilla style formatting/indenting.
Linux braces, with broken braces for structs and enums,
and attached braces for namespaces.--style=pico OR -A11
Pico style formatting/indenting.
Run-in opening braces and attached closing braces.
Uses keep one line blocks and keep one line statements.--style=lisp OR -A12
Lisp style formatting/indenting.
Attached opening braces and attached closing braces.
Uses keep one line statements.
Tab Options:
default indent option
If no indentation option is set, the default
option of 4 spaces per indent will be used.--indent=spaces=# OR -s#
Indent using # spaces per indent. Not specifying #
will result in a default of 4 spaces per indent.--indent=tab OR --indent=tab=# OR -t OR -t#
Indent using tab characters, assuming that each
indent is # spaces long. Not specifying # will result
in a default assumption of 4 spaces per indent.--indent=force-tab=# OR -T#
Indent using tab characters, assuming that each
indent is # spaces long. Force tabs to be used in areas
AStyle would prefer to use spaces.--indent=force-tab-x=# OR -xT#
Allows the tab length to be set to a length that is different
from the indent length. This may cause the indentation to be
a mix of both spaces and tabs. This option sets the tab length.
Brace Modify Options:
--attach-namespaces OR -xn
Attach braces to a namespace statement.--attach-classes OR -xc
Attach braces to a class statement.--attach-inlines OR -xl
Attach braces to class inline function definitions.--attach-extern-c OR -xk
Attach braces to an extern "C" statement.--attach-closing-while OR -xV
Attach closing while of do-while to the closing brace.
Indentation Options:
--indent-classes OR -C
Indent 'class' blocks so that the entire block is indented.--indent-modifiers OR -xG
Indent 'class' access modifiers, 'public:', 'protected:' or
'private:', one half indent. The rest of the class is not
indented.--indent-switches OR -S
Indent 'switch' blocks, so that the inner 'case XXX:'
headers are indented in relation to the switch block.--indent-cases OR -K
Indent case blocks from the 'case XXX:' headers.
Case statements not enclosed in blocks are NOT indented.--indent-namespaces OR -N
Indent the contents of namespace blocks.--indent-after-parens OR -xU
Indent, instead of align, continuation lines following lines
that contain an opening paren '(' or an assignment '='.--indent-continuation=# OR -xt#
Indent continuation lines an additional # indents.
The valid values are 0 thru 4 indents.
The default value is 1 indent.--indent-labels OR -L
Indent labels so that they appear one indent less than
the current indentation level, rather than being
flushed completely to the left (which is the default).--indent-preproc-block OR -xW
Indent preprocessor blocks at brace level 0.
Without this option the preprocessor block is not indented.--indent-preproc-cond OR -xw
Indent preprocessor conditional statements #if/#else/#endif
to the same level as the source code.--indent-preproc-define OR -w
Indent multi-line preprocessor #define statements.--indent-col1-comments OR -Y
Indent line comments that start in column one.--min-conditional-indent=# OR -m#
Indent a minimal # spaces in a continuous conditional
belonging to a conditional header.
The valid values are:
0 - no minimal indent.
1 - indent at least one additional indent.
2 - indent at least two additional indents.
3 - indent at least one-half an additional indent.
The default value is 2, two additional indents.--max-continuation-indent=# OR -M#
Indent a maximal # spaces in a continuation line,
relative to the previous line.
The valid values are 40 thru 120.
The default value is 40.
Padding Options:
--break-blocks OR -f
Insert empty lines around unrelated blocks, labels, classes, ...--break-blocks=all OR -F
Like --break-blocks, except also insert empty lines
around closing headers (e.g. 'else', 'catch', ...).--pad-oper OR -p
Insert space padding around operators.--pad-comma OR -xg
Insert space padding after commas.--pad-paren OR -P
Insert space padding around parenthesis on both the outside
and the inside.--pad-paren-out OR -d
Insert space padding around parenthesis on the outside only.--pad-first-paren-out OR -xd
Insert space padding around first parenthesis in a series on
the outside only.--pad-paren-in OR -D
Insert space padding around parenthesis on the inside only.--pad-header OR -H
Insert space padding after paren headers (e.g. 'if', 'for'...).--unpad-paren OR -U
Remove unnecessary space padding around parenthesis. This
can be used in combination with the 'pad' options above.--delete-empty-lines OR -xd
Delete empty lines within a function or method.
It will NOT delete lines added by the break-blocks options.--fill-empty-lines OR -E
Fill empty lines with the white space of their
previous lines.--align-pointer=type OR -k1
--align-pointer=middle OR -k2
--align-pointer=name OR -k3
Attach a pointer or reference operator (*, &, or ^) to either
the operator type (left), middle, or operator name (right).
To align the reference separately use --align-reference.--align-reference=none OR -W0
--align-reference=type OR -W1
--align-reference=middle OR -W2
--align-reference=name OR -W3
Attach a reference operator (&) to either
the operator type (left), middle, or operator name (right).
If not set, follow pointer alignment.
Formatting Options:
--break-closing-braces OR -y
Break braces before closing headers (e.g. 'else', 'catch', ...).
Use with --style=java, --style=kr, --style=stroustrup,
--style=linux, or --style=1tbs.--break-elseifs OR -e
Break 'else if()' statements into two different lines.--break-one-line-headers OR -xb
Break one line headers (e.g. 'if', 'while', 'else', ...) from a
statement residing on the same line.--add-braces OR -j
Add braces to unbraced one line conditional statements.--add-one-line-braces OR -J
Add one line braces to unbraced one line conditional
statements.--remove-braces OR -xj
Remove braces from a braced one line conditional statements.--break-return-type OR -xB
--break-return-type-decl OR -xD
Break the return type from the function name. Options are
for the function definitions and the function declarations.--attach-return-type OR -xf
--attach-return-type-decl OR -xh
Attach the return type to the function name. Options are
for the function definitions and the function declarations.--keep-one-line-blocks OR -O
Don't break blocks residing completely on one line.--keep-one-line-statements OR -o
Don't break lines containing multiple statements into
multiple single-statement lines.--convert-tabs OR -c
Convert tabs to the appropriate number of spaces.--close-templates OR -xy
Close ending angle brackets on template definitions.--remove-comment-prefix OR -xp
Remove the leading '*' prefix on multi-line comments and
indent the comment text one indent.--max-code-length=# OR -xC#
--break-after-logical OR -xL
max-code-length=# will break the line if it exceeds more than
# characters. The valid values are 50 thru 200.
If the line contains logical conditionals they will be placed
first on the new line. The option break-after-logical will
cause the logical conditional to be placed last on the
previous line.--mode=c
Indent a C or C++ source file (this is the default).--mode=java
Indent a Java source file.--mode=cs
Indent a C# source file.
Objective-C Options:
--pad-method-prefix OR -xQ
Insert space padding after the '-' or '+' Objective-C
method prefix.--unpad-method-prefix OR -xR
Remove all space padding after the '-' or '+' Objective-C
method prefix.--pad-return-type OR -xq
Insert space padding after the Objective-C return type.--unpad-return-type OR -xr
Remove all space padding after the Objective-C return type.--pad-param-type OR -xS
Insert space padding after the Objective-C return type.--unpad-param-type OR -xs
Remove all space padding after the Objective-C return type.--align-method-colon OR -xM
Align the colons in an Objective-C method definition.--pad-method-colon=none OR -xP
--pad-method-colon=all OR -xP1
--pad-method-colon=after OR -xP2
--pad-method-colon=before OR -xP3
Add or remove space padding before or after the colons in an
Objective-C method call.
Other Options:
--suffix=####
Append the suffix #### instead of '.orig' to original filename.--suffix=none OR -n
Do not retain a backup of the original file.--recursive OR -r OR -R
Process subdirectories recursively.--dry-run
Perform a trial run with no changes made to check for formatting.--exclude=####
Specify a file or directory #### to be excluded from processing.--ignore-exclude-errors OR -i
Allow processing to continue if there are errors in the exclude=####
options. It will display the unmatched excludes.--ignore-exclude-errors-x OR -xi
Allow processing to continue if there are errors in the exclude=####
options. It will NOT display the unmatched excludes.--errors-to-stdout OR -X
Print errors and help information to standard-output rather than
to standard-error.--preserve-date OR -Z
Preserve the original file's date and time modified. The timemodified will be changed a few micro seconds to force a compile.--verbose OR -v
Verbose mode. Extra informational messages will be displayed.--formatted OR -Q
Formatted display mode. Display only the files that have been
formatted.--quiet OR -q
Quiet mode. Suppress all output except error messages.--lineend=windows OR -z1
--lineend=linux OR -z2
--lineend=macold OR -z3
Force use of the specified line end style. Valid options
are windows (CRLF), linux (LF), and macold (CR).
Command Line Only:
--options=####
--options=none
Specify a default option file #### to read and use.
It must contain a file path and a file name.
'none' disables the default option file.--project
--project=####
--project=none
Specify a project option file #### to read and use.
It must contain a file name only, without a directory path.
The file should be included in the project top-level directory.
The default file name is .astylerc or _astylerc.
'none' disables the project or environment variable file.--ascii OR -I
The displayed output will be ascii characters only.--version OR -V
Print version number.--help OR -h OR -?
Print this help message.--html OR -!
Open the HTML help file "astyle.html" in the default browser.
The documentation must be installed in the standard install path.--html=####
Open a HTML help file in the default browser using the file path
####. The path may include a directory path and a file name, or a
file name only. Paths containing spaces must be enclosed in quotes.--stdin=####
Use the file path #### as input to single file formatting.
This is a replacement for redirection.--stdout=####
Use the file path #### as output from single file formatting.
This is a replacement for redirection.
辅助开发: Keil中使用Aystyle 快速格式化所有代码相关推荐
- 在Keil中利用AStyle插件格式化代码
平时在用keil调试程序的时候,代码默认情况下不能自动调整格式.需要手动调整格式,比较麻烦.通过AStyle插件可以很方便的自动调整代码格式.下面总结一个AStyle插件的使用方法. 首先在官网上下载 ...
- WPF中,使用快捷键格式化XAML代码
开发环境 VS2015 Enterprise update 3 解决方案 总体来讲: - 设置格式化效果 - 使用快捷键格式化 1.设置格式化效果 2.所使用快捷键进行格式化 选中要格式化的XAML代 ...
- java编码规范文档 下载_软件项目实训及课程设计指导——制定待开发项目中各种文档的规范...
软件项目实训及课程设计指导--制定待开发项目中各种形式文档的规范 1.制定对课程设计项目开发过程中的规范性要求 (1)从"形式"到"内容"两个方面控制和要求开发 ...
- Notepad++格式化JS代码
Notepad++是自由软件的纯文本编辑器,在文字编辑方面与 Windows 写字板功能相当.是一款开源.小巧.免费的纯文本编辑器. 1.打开Notepad++,选择 插件管理 2.在插件列表中找到J ...
- qt creator插入代码块快速注释snippets代码片段的功能
定义 任何开发IDE中,一般都提供snippets代码片段的功能,就是为了方便快捷的插入格式一致的代码段或者注释段. 步骤 qt creator 添加头文件,源文件的注释功能. 在qt creator ...
- python嵌入式系统开发技术_Python在嵌入式项目中的辅助开发_彭树林
效率和质量至关重要.本文要介绍的Python脚本语言和众多 第三方函数库就是这样的利器:易学.高效.功能强,值得推 广. 1 Python简介 Python是一种流行的动态脚本语言,经历了十多年的发展 ...
- python嵌入式系统开发_Python在嵌入式项目中辅助开发.PDF
22 SYSPRACTICE 系统实践 on在嵌入式项目中的辅助开发 Pyth 彭树林 摘要:嵌入式系统设计开发过程中常会遇到诸如算法分析.原型验证.自动化测试.辅助工具设计等工作,其 开发效率和质量 ...
- react 快速上手开发_React中测试驱动开发的快速指南
react 快速上手开发 by Michał Baranowski 通过MichałBaranowski React中测试驱动开发的快速指南 (A quick guide to test-driven ...
- 转载:keil中使用Astyle格式化你的代码的方法2篇合
转自:https://blog.csdn.net/STM32F4/article/details/46649353 关于Astyle Astyle 的全称是Artistic Style的简称,是一个开 ...
最新文章
- 【图解】最流行的7个JavaScript 框架各自的优点
- 深度学习 常用python操作(1)
- Asp.net采集用到的幾個方法
- HttpHandler与HttpModule的用处与区别
- php+js实现弹幕,jquery.barrager.js-专业的网页弹幕插件
- 一文读懂Java多线程原理
- OpenCV-浮雕雕刻效果
- Winform窗体控件自适应大小
- CCF - 201604-2 - 俄罗斯方块
- python删除word表格中的某一行_python-docx添加和删除表格行、列
- javacv获取摄像头列表
- 转行学IT,能找到好工作吗?
- 利用python提取基因cDNA长度,exon数量,pep长度和PI
- 【hadoop系列】Hadoop HDFS命令
- Linux之Ubuntu20.04安装Java JDK8的两种方式
- GPT系列:GPT1 -> 2 -> 3 -> InstructGPT ->ChatGPT
- 数字电路3-8译码器
- RFC系列协议--rfc2373--IP Version 6 Addressing Architecture
- 程序员如何用技术变现?(取其精华去其糟粕)
- MXshine即将全球首发Grin和Beam交易
热门文章
- 史上最强像素画教程「Pixel Art2」像素食物構圖教學本
- python实现综合评价模型TOPSIS
- javaweb习题集
- 实用的短视频推广软件 抖音短视频推广助手
- 【手把手教你树莓派3 (六)】使用 motion 和 mjpg 做视频监控器
- 轨交7号线正式运营 沿线在售升值潜力盘推荐
- 【转】运行维护管理制度
- html ios键盘收回后输入框点不动,iOS下Html页面中input获取焦点弹出键盘时挡住input解决方案...
- 计算机二级如何保存文档,计算机二级 (自动保存的) (自动保存的)
- 最新版---火绒杀毒5.0-sysdiag-full-5.0.43.7.exe