I am writing a program in C that must act differently based on a definition or not a symbolic constant. For a simple example, my first thought was to write this as follows:
#include <stdio.h>
#define TEST
int main(void) {
int num;
#ifdef TEST
num=1;
printf("YES\n");
#else
num=0;
printf("NO\n");
#endif
printf("%d\n", num);
return 0;
}
However, when trying to auto-render my code (in particular, using gg=Gin vim) my indentation was lost:
#include <stdio.h>
#define TEST
int main(void) {
int num;
#ifdef TEST
num=1;
printf("YES\n");
#else
num=0;
printf("NO\n");
#endif
printf("%d\n", num);
return 0;
}
Of course, if I try to auto-delay something like the following (with the actual commands in between), the following occurs:
#ifdef TEST1
commands
#ifdef TEST2
commands
#else
#ifdef TEST3
commands
#endif
commands
#endif
#endif
So, is there anything I can do to have the indentation indicated above by default?
source
share