我先介绍这个怎么在notepad++中调用原版的astyle的方法。

在notepad++:运行或是F5,

 

 

在输入框中选择astyle.exe所在的目录,什么你没有astyle,下载地址https://files.cnblogs.com/files/libra13179/AStyle_2.06_windows.zip或者关于Astyle的介绍帮助及下载,请参考其官方网站:http://astyle.sourceforge.net/。建议解压的路径不要中文。

路径选择好后,

我的安装路径E:\AStyle_2.06_windows\AStyle\bin\AStyle.exe

在刚才运行的输入框命令的路径添加一些参数就是:E:\AStyle_2.06_windows\AStyle\bin\AStyle.exe --style=ansi -S -N -n "$(FULL_CURRENT_PATH)" "$(FULL_CURRENT_PATH)"

【备注】--style=ansi -S -N -n为astyle设置排版的格式的参数,可以根据自己情况修改
之后单击保存,

 

给它起个名字,比如,astyle就好了,还可以定制快捷键,根据你自己的需要吧!

后期想修改的话可以在快捷键管理自行修改

 


最后还要"设置"->"首选项"->"其他",把自动更新给勾上,就好了,大事告成

 如果想添加一堆配置文件

可以"C:\Program Files\AStyle\AStyle.exe" --options="C:\Program Files\AStyle\astyle.config" "$(FULL_CURRENT_PATH)" "$(FULL_CURRENT_PATH)"

astyle.config配置文件如下

# http://astyle.sourceforge.net/astyle.html
#******************************************************************************
--style=ansi

#******************************************************************************
--indent=spaces=4
# Indent using 4 spaces per indent.

#******************************************************************************
--pad-oper
# Insert space padding around operators.
# e.g.  "if (var>0)"---->  "if (var > 0)"

#******************************************************************************
--pad-header
# Insert space padding between a header (e.g. 'if', 'for', 'while'...) and the following paren. 
# Insert space padding after paren headers only (e.g. 'if', 'for', 'while'...)
# e.g. "if(xx)" --------> "if (xx)"

#******************************************************************************
--delete-empty-lines
# Delete empty lines within a function or method. 
# Empty lines outside of functions or methods are NOT deleted.


#******************************************************************************
--convert-tabs
# Converts tabs into spaces in the non-indentation part of the line.

#******************************************************************************
--add-brackets
# Add brackets to unbracketed one line conditional statements.
# e.g.
# if (isFoo)
#     isFoo = false;
# Becomes:
# if (isFoo) 
# {
#     isFoo = false;
# }

#******************************************************************************
--align-pointer=name
# Attach a pointer or reference operator (*, &, or ^) to variable name(right).
# e.g.  "UINT8* a, b;" --------> "UINT8 *a, b;"

#******************************************************************************
--min-conditional-indent=0

#******************************************************************************
--max-code-length=80

#******************************************************************************
--max-instatement-indent=80

#******************************************************************************
# --lineend=linux
--lineend=windows
# Force use of the specified line end style. 
# Valid options are windows (CRLF), linux (LF), and macold (CR). 

#******************************************************************************
--suffix=.pre
#Append the suffix .pre instead of '.orig' to original filename 

#******************************************************************************
--mode=c

#******************************************************************************
--indent-switches 
# Indent 'switch' blocks so that the 'case X:' statements are indented 
# in the switch block. The entire case block is indented.


#******************************************************************************
#Is these ok?  the follow list command.
#******************************************************************************
# --break-blocks
# Pad empty lines around header blocks (e.g. 'if', 'for', 'while'...).

#******************************************************************************
--indent-preproc-block
# Indent preprocessor blocks at bracket level zero, and immediately within a namespace.
# There are restrictions on what will be indented. 
# Blocks within methods, classes, arrays, etc, will not be indented. 
# Blocks containing brackets or multi-line define statements will not be indented. 
# Without this option the preprocessor block is not indented.
# e.g. fmc_can_hal.h  line 194
View Code

好了测试一下我们故意将代码排版弄乱

运行刚才设置快捷方式

自动整理后

 

posted on 2018-06-01 10:11  陌鉎こ城sHi  阅读(28485)  评论(1编辑  收藏  举报