1

Title says it all really, but to elaborate, in my preferences.txt file, I've changed the editor.tabs.size variable to 4, which works wonderfully, and now produces 4-space tabs as do my other IDEs for all the languages I write in.

However, I was told that using the Tools->AutoFormat feature would update all lines in my previously-written sketches that had the standard 2-space tabs with the new 4-space tab layout.

This isn't so. Whether I CTRL-a to select all and run the Auto Format function, or whether I leave everything de-selected, nothing happens.

Should auto-format "fix" the 'incorrect' indenting to the new style? If so, what am I missing?

I'm currently on Arduino IDE 1.8.5 on Linux Mint, if that makes a difference.

1 Answer 1

3

The auto formatter (astyle) uses a separate configuration to the editor (crazy, I know, but that's the Arduino mentality for you...).

It uses a separate configuration, which is in the lib folder of your Arduino program, called formatter.conf.

  • Copy that file to the same location as preferences.txt so it doesn't get overwritten when you upgrade the IDE.
  • Edit the file and change indent=spaces=2 to indent=spaces=4

The auto format should now be the same as the editor format.

4
  • Good grief. I'll test it here shortly @Majenko. Thanks
    – stevieb
    Commented Sep 9, 2019 at 21:24
  • Wow. What a meticulously ridiculous way to do things. Answer accepted as it worked. I'll have to make notes for this and update my automation routines, as I can see this going downhill in the future on new setups.
    – stevieb
    Commented Sep 9, 2019 at 21:28
  • 1
    The auto formatter (astyle) uses a separate configuration to the editor - with what possible justification?
    – Nick Gammon
    Commented Sep 10, 2019 at 9:51
  • @NickGammon I wish I knew. When I implemented astyle in UECIDE it just read the same formatting settings (plus extras that don't apply) for the editor...
    – Majenko
    Commented Sep 10, 2019 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.