Go Down

Topic: Minor IDE Auto Format gripe (Read 2643 times) previous topic - next topic

Geek Emeritus

if I auto format this already formatted bit of code I get

Code: [Select]
void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}


I would much prefer

Code: [Select]
void setup()
{  // this bracket on the left directly above
}  // its companion bracket. orderly appearance, simpler comparison of opening and closing brackets

void loop()
{   // this bracket on the left directly above
}   // its companion bracket. orderly appearance, simpler comparison of opening and closing brackets


is this an unreasonable request?
All PMs will be deleted unopened due to arrogant argumentative pot stirring Malfoys.
 If you have not read "How to use this forum - please read", in particular: "7. If you are posting code or error messages, use "code" tags":  expect rude responses

spycatcher2k

Personal choice - just edit the bare bones example file with notepad and save it over itself.
Mrs Drew
-=-
UK Based PCB Manufacturing - PM for details
I will design & code for you, but I will also charge you (PM me)
Use Google or search this site BEFORE asking!

pert

You can configure the Arduino IDE's Auto Format tool to your preference. The file is at {Arduino IDE installation folder}/lib/formatter.conf.

The configuration options for brace style are documented here:
http://astyle.sourceforge.net/astyle.html#_Basic_Brace_Styles

So if you like the Allman brace style, you would add this to the file:
Code: [Select]
style=allman

GaryP

#3
Jan 26, 2020, 09:38 am Last Edit: Jan 26, 2020, 09:39 am by GaryP
Thank you!

I didn't understand to ask this, I just suffer in silence!!!

Cheers,
Kari

The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

pert

You're welcome. I'm glad if I was able to be of assistance.

One thing I should mention is that if the Arduino IDE is running you need to restart it before changes to formatter.conf take effect.

Also note the helpful comment in formatter.conf:
Code: [Select]
# If you wish to change them, don't edit this file.
# Instead, copy it in the same folder of file "preferences.txt" and modify the copy. This way, you won't lose your custom formatter settings when upgrading the IDE
# If you don't know where file preferences.txt is stored, open the IDE, File -> Preferences and you'll find a link

You can find the location of the folder by clicking the link on the line following "More preferences can be edited directly in the file" in the Arduino IDE's File > Preferences.

Go Up