不足
Shortly after starting to use this macro on a regular basis, I noticed that I was having problems with copy and paste functionality in MSDev. Basically I could copy something but would not be able to paste it (Ctrl-V stopped working, Shift-Insert stopped working, even pasting from context menus stopped working). Sometimes I could defeat it by copying from one file, pasting into another (like notepad), copying from there and then pasting into the file I originally wanted to paste into. Needless to say it was frustrating. This started happening shortly after I switched to Win2K and around the same time I started using the macro. For a while I thought it was Win2K, but I eventually noticed the correspondence between using the MakeCodeNicer macro and the copy paste bug. In general, it only happens after using the macro on relatively large files (a thousand lines up to several thousand). So, this is just a heads up to anyone using this macro. It seems like the large amount of text modification it does brings out a bug in VC 6's macro language or clip board functionality. Also, I'm not sure if this happens anywhere but Win2K. To the author: great work... this is a huge time saver for me! |
astyle [options] Source1.cpp Source2.cpp [...]
astyle [options] < Original > Beautified格式化后会把原来的文件后缀加上“orig”。
下面通过例子进行说明:
astyle --options=conf.txt test.cpp
上边的命令通过配置文件conf.txt中的选项来格式化文件test.cpp,为了使得astyle命令能够找到可以采用以下三种方法:
1.把conf.txt文件放到与satyle.exe同一目录下
2.指定conf.txt的绝对路径,例如astyle --options=c://conf.txt test.cpp,如果绝对路径中含有空格,则写为:astyle --options=“c://have two spaces//conf.txt” test.cpp
3.指定环境变量。令环境变量名为USERPROFILE,然后值为options文件的路径。
同理,为了能让astyle找到test.cpp文件,也需要采用上述三种方法之一。
其中conf.txt文件格式最后再说。
可以根据帮助文件中的options选项来对这个文件进行修改。
可以参考http://hi.baidu.com/0x01/blog/item/3111b311d4f5ed7fcb80c4af.html
另外,在 http://www.geocities.com/jpattee/astylewin/doc/Options.html 有一款专门用于windows的Artistic Style for Windows。可以通过工具--》选项以及设置来设置格式(以动态界面显示设置),然后打开特定文件来格式化。其不足是一次只能格式化一个文件,但是,我们可以使用其配置文件,其配置文件AStyleWin.ini的位置要么在类似C:/Documents and Settings/Administrator/Application Data的目录下,要么与AStyleWin.exe在同一目录下。
# set default parsing to c/cpp files
mode=c
# brackets should be attached to pre-bracket lines
brackets=break
# set 6 spaces per indent
indent=spaces=4
suffix=.pre
indent-switches
indent-classes
indent-cases
indent-namespaces
indent-labels
indent-preprocessor
recursive
indent-namespaces
max-instatement-indent=80
min-conditional-indent=0
break-blocks
pad=oper
unpad=paren
convert-tabs