Dev-C++添加代码格式化(format source code)工具Artistic Style

Dev-C++是一个轻便的C++ IDE开发环境,比起VS2010来轻巧得多。最新的版本是5.4.0是2013年2月14日发布的,下载地址如下:

Dev-C++5.4.0 download

它是开源项目,不过,他没有像VS那样的代码格式化工具,所以要安装第三方开源插件。

起初我在网上找这样的插件,找到这篇文章:Integrate FormatCode Into Dev-C++

但悲剧的是那个工具的下载链接有问题(不知道是不是我这边网络问题)。

后来找到了另一个非常好的工具:Artistic Style,他的说明和下载如下(下载后我解压后放在G:根目录下):

Artistic Style.

Artistic Style Download.

下载好了以后,在Dev-C++中设置(按照文章:Integrate FormatCode Into Dev-C++):

Tools->Configure Tools->Add  


设置好了以后(设置参数见安装文件,我这里设置gnu风格),我有如下代码:


然后Tools->AStyle进行。但我发现这贷Artistic Style最新版本的是2011年的所以跟2013年的Dev-C++不是很“协调”。

即使这个设置是正确的,但仍然有时候不成功。

所以只有在命令行(cmd)下用Artistic Style这个工具,如下:


你如果已经在Dev-C++中已经打开了demo.cpp,可能跳出如下窗口:


关闭(Ctrl+W)demo.cpp再打开得到排版好的啦:


  • 7
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
包含源代码,需要的可以自行下载。 把astyle.exe 复制到 C:\WINDOWS 目录里,省的指定路径 VC6++ 设置方法 菜单->工具->定制->工具菜单内容->新建菜单,参数如下 命令行:astyle.exe 变量: --style=k&r --brackets=break --indent=spaces --indent-cases --indent-preprocessor --pad-header --pad-oper --unpad-paren --keep-one-line-statements --keep-one-line-blocks --convert-tabs $(FileName)$(FileExt) 初始目录: $(FileDir) VC2008 外部工具里设置,还可以添加快捷键 命令:astyle.exe 参数: --style=k&r --brackets=break --indent=spaces --indent-cases --indent-preprocessor --pad-header --pad-oper --unpad-paren --keep-one-line-statements --keep-one-line-blocks --convert-tabs $(ItemFileName)$(ItemExt) 初始目录: $(ItemDir) CodeBlocks 设置差不多,很多绿色版的已经设置好了 AStyle_2.02_windows.zip bin 目录里有官方编译好的 Artistic Style 2.01 Maintained by: Jim Pattee Original Author: Tal Davidson Usage : astyle [options] Source1.cpp Source2.cpp [...] astyle [options] Beautified When 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. By default, astyle is set up to indent C/C++/C#/Java files, 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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值