Read this, it doesn't take too long, around 2 hours , it'll seem like 30mins
and it'll help you understand things and save lots of time
From Part 15 of the above book:
Is there any reason for the formatting of the above three functions is not consistent in terms of opening brace and closing brace which are aligned for the DashedLine() function and not for setup() and loop() functions?
Yes. Laziness
Which one of the following is recommended?
void setup() {
}
or
void setup()
{
}
For me the second one, but others will no doubt disagree. I have Auto format in the IDE configured to use this format
Do you use a consistent style and, if so, which and why ?
I have seen for myself and for the pupils to loose/miss the closing/matching brace if not using the aligned version (second one of post #16). I use the aligned version as it helps to use a ruler to find the missing/matching brace quickly in a deeply nested sketch involving if-else/switch-case.
No need for a ruler as the IDE connects the matching pairs of braces with vertical lines
How to bring those vertical lines in the IDE? Checking the "Display line numbers" box in the preference menu does bring only the line numbers and not the vertical lines. I use IDE 1.8.19.
I am using IDE 2.1.1
Ok! I will try with IDE 2.1.1.
Thanks!
No, i prefer the second as well
Split from another topic as this discussion had wandered away from the original topic subject
I prefer that one. Probably comes from spending too much time programming on 24-line terminals. (also, the "2nd" form looks uncomfortably like an old-style C function, which I'd rather not remember.)
By-the-by, which style does Arduino Forum follow for the title of a thread -- I mean?:
Function brace style
or
Function Brace Style
The style used in a forum title is, of course, the choice of the person who started (or edited) the topic title
The forum itself has no opinion on the matter
I have installed IDE 2.1.1 where the "Blink" example bears the following format showing opening brace at the end of the function name. The vertical line is there but not aligned with opening/closing braces (Fig-1). The programmer needs to bring the opening brace at the newline position manually (Fig-2).
Figure-1:
Figure-2:
Echo....Me too, don't know why though.
I am not sure what your point is
You could configure Auto Format to do it for you
I've found links to autoformat configuration for IDE 2.x, on the Arduino.cc website and elsewhere, but I haven't found same for V1.x - is there something I've missed?
I don't think there is any formal official documentation of it. You will find some information about it on the forum. For example:
If the information provided there is not sufficient, the useful keywords are "formatter.conf", "astyle", or "artistic style".