如何在vim中使用大量参数调试/重新格式化C printf调用?

Cos*_*sti 2 c vim

我在一个程序中有一个函数调用,我正在维护有一个printf调用的28个参数.它在CSV文件中打印了大量数据.我发现问题发生了什么,我在参数类型中遇到了一些不匹配问题.我在gcc中启用了-Wall,我收到警告:

n.c:495: warning: int format, pointer arg (arg 15)
n.c:495: warning: format argument is not a pointer (arg 16)
n.c:495: warning: double format, pointer arg (arg 23)
Run Code Online (Sandbox Code Playgroud)

功能是这样的:

fprintf (ConvFilePtr, "\"FORMAT3\"%s%04d%s%04d%s%s%s%d%s%c%s%d%c%s%s%s%s%s%s%s%11.lf%s%11.lf%s%11.lf%s%d\n", some_28_arguments_go_here);
Run Code Online (Sandbox Code Playgroud)

我想知道当我将光标放在变量上时是否有一个vim插件突出显示printf格式说明符.

其他方案?如何更好地重新格式化代码以使其更具可读性?

ram*_*ion 5

不知道我知道一个很好的vim技巧,但我知道一个好的C宏,使它更容易:

#define last( f, a, ft, ... ) f ft, a, __VA_ARGS__
#define pair( f, a, ftat ) last( f, a, ftat )
// ...
printf( pair( "%s", "hello",
        pair( "%s", "world",
        pair( "%c", '\n',
        last( "%4x", 0xfeed,
              "%f\n", 3.14159 )))));
Run Code Online (Sandbox Code Playgroud)