Setting tabs for code formatting

You can influence the behaviour of the auto format. You will need to create a file called .clang-format (note the dot) in the configuration directory. You can find where the configuration directory for your operating system is at https://support.arduino.cc/hc/en-us/articles/4415103213714-Find-sketches-libraries-board-cores-and-other-files-on-your-computer#boards (search for Configuration folder).

You can find the .clang-format that is used by default at arduino-examples/.clang-format at main · arduino/arduino-examples · GitHub.
I've attached my .clang-format file; it contains some more changes like "Allman" to get braces on new lines for conditional statements. My changes are commented with WS.
It should be safe but run a virus scanner over it to be sure.

Search the .clang-format file for IndentWidth: 2 and change the value. Save the file; you do not need to restart the IDE when making changes to that file.

.clang-format.zip (2.0 KB)

Notes

  1. There are a few more indent settings.
  2. You can test at http://clang-format-configurator.site/
  3. As a guide for the various settings you can consult Clang-Format Style Options — Clang 23.0.0git documentation; the IDE does not use that version, I think it's version 13 (not sure).