寻找比GNU缩进更灵活的工具

时间:2008-09-19 13:30:22

标签: pretty-print indentation

当我使用各种选项运行缩进时,我想要反对我的源代码,它可以实现我想要的功能,但也会因为指针类型中的* s的位置而混乱:

  -int send_pkt(tpkt_t* pkt, void* opt_data);
  -void dump(tpkt_t* bp);
  +int send_pkt(tpkt_t * pkt, void *opt_data);
  +void dump(tpkt * bp);

我知道我在类型旁边放置* s而不是变量是非常规的但是我怎么能让它们单独留下来缩进?或者是否有另一种工具可以满足我的需求?我查看了手册页,信息页面,并访问了谷歌建议的六个页面,我找不到这样做的选项。

我尝试过艺术风格(a.k.a. AStyle),但似乎无法弄清楚如何以4的倍数缩进,但每8个标签。那就是:

if ( ... ) {
<4spaces>if ( ... ) {
<tab>...some code here...
<4spaces>}
}

2 个答案:

答案 0 :(得分:17)

Uncrustify

Uncrustify有几个关于如何缩进文件的选项。

从配置文件:

indent_with_tabs                           
  How to use tabs when indenting code  
  0=spaces only  
  1=indent with tabs, align with spaces  
  2=indent and align with tabs

你可以找到它here

<强> BCPP
从网站:“bcpp缩进C / C ++源程序,用空格替换制表符或反过来。与缩进不同,它(按设计)不会尝试包装长语句。”
找到它here

<强> UniversalIndentGUI
它是一个支持几个美化/格式化程序的工具。它可以引导你更多的选择。
找到它here

艺术风格
您可以尝试使用Artistic Style aka AStyle(即使它没有按照您的需要执行操作,我会将其留在此处,以防其他人发现它有用)。

答案 1 :(得分:2)

围绕并改变其编辑代码的行为。毕竟它是GNU。 ; - )

因为它可能不是您想要的答案,所以这是另一个链接:http://www.fnal.gov/docs/working-groups/c++wg/indenting.html