1

in my school we use a coding convention, which specifies to separate the name of the variable and its type (in C). In emacs, it would look like this :

static int        calc_dir(t_exe *exe, const int id)
{
  int             x0, y0;
  int             x1, y1;
}

Another convention is to use tabulations when possible, so here there are tabs between var/functions types and names. I actually want to switch from emacs to atom editor. I tried to play with a lot of options in uncrustify, to format my code, but I still can't find a way to do this : indent var names with the function name... All I got was to be able to specify an "absolute" number of columns between types and names, with the align_var_def_gap option, but its absolute, and does not fit if the function name (here "calc_dir")is, let's say 1 tabulation after...

static int       calc_dir(t_exe *exe, const int id)
{
  int    x0, y0;
  int    x1, y1;
}

It would be great if anyone had a config, or an idea !

Nathan Basanese
  • 8,475
  • 10
  • 37
  • 66
Theo Pnv
  • 402
  • 5
  • 14
  • (but versions look awful, btw. and are considered bad practice according to many reasonable style-guides) – too honest for this site Oct 24 '16 at 23:16
  • 3
    I posted images because its a question about formatting, and it's easier to understand by looking at the two different editors/configs. – Theo Pnv Oct 24 '16 at 23:18
  • 2
    And I'm sorry, I can't change my school's coding convention... I was just asking for some help on the options of uncrustify. – Theo Pnv Oct 24 '16 at 23:20
  • 1
    How many spaces to put in a declaration between the type and the variable name is among the least interesting questions in C programming. (How to automate this process is even less interesting.) You should be devoting 5% or less of your energy to questions like this, and the other 95% to things that really matter. If your school is making a big deal out of things like this, they need to readjust their priorities. (Mind you, I'm not saying indentation and layout aren't important, but they're not *that* important.) – Steve Summit Oct 24 '16 at 23:27
  • "school's coding convention" - every sane senior will complain on that style. So much for "school prepares for life". Anyway, you can very well show the formatting as text. No need for images. – too honest for this site Oct 24 '16 at 23:58
  • // , On the other hand, learning how to deal flexibly with whatever weird style conventions a given project or organization has can come in handy in "life" – Nathan Basanese Sep 26 '18 at 20:54

0 Answers0