问题描述
当我对源使用各种选项进行缩进时,它可以实现我想要的功能,但同时也会使* s在指针类型中的位置混乱:
When I run indent with various options I want against my source, it does what I want but also messes with the placement of *s in pointer types:
-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在类型旁边的放置不是变量是非常规的,但是我怎么能缩进以使其保持不变呢?还是有另一种工具可以满足我的需求?我已经浏览了手册页,信息页,并访问了Google建议的六个页面,但我找不到执行此操作的选项.
I know my placement of *s next to the type not the variable is unconventional but how can I get indent to just leave them alone? Or is there another tool that will do what I want? I've looked in the man page, the info page, and visited a half a dozen pages that Google suggested and I can't find an option to do this.
我尝试了艺术风格"(又称AStyle),但似乎无法弄清楚如何以4的倍数缩进,但每8个制表符为一个.那就是:
I tried Artistic Style (a.k.a. AStyle) but can't seem to figure out how to make it indent in multiples of 4 but make every 8 a tab. That is:
if ( ... ) {
<4spaces>if ( ... ) {
<tab>...some code here...
<4spaces>}
}
推荐答案
取消外壳
Uncrustify提供了几种有关如何缩进文件的选项.
Uncrustify has several options on how to indent your files.
从配置文件中:
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
您可以在此处找到它.
BCPP
从网站上:"bcpp使C/C ++源程序缩进,用空格或反斜杠代替制表符.与缩进不同,它(在设计上)不尝试包装长语句."
在此处找到.
BCPP
From the website: "bcpp indents C/C++ source programs, replacing tabs with spaces or the reverse. Unlike indent, it does (by design) not attempt to wrap long statements."
Find it here.
UniversalIndentGUI
这是一个支持多个美化器/格式化程序的工具.它可能会导致您有更多选择.
在此处找到它.
UniversalIndentGUI
It's a tool which supports several beautifiers / formatters. It could lead you to even more alternatives.
Find it here.
艺术风格
您可以尝试使用 Artistic Style aka AStyle (即使它并没有满足您的要求,我'将其保留在这里,以防其他人发现它有用).
Artistic Style
You could try Artistic Style aka AStyle instead (even though it doesn't do what you need it to do, I'll leave it here in case someone else finds it useful).
这篇关于寻找比GNU Indent更灵活的工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!