IDE 2.1.0 Tab Stops?

Hi,

I can't figure out where in the IDE to change the width of the tab stops. There is nothing under file-preferences for the editor that I can see? This seems crazy to me that 2 spaces, as a default, is good for anyone !?!?

Thanks!

Hi @mottretop. There are two separate systems to configure:

  • Indentation style while editing
  • Indentation style of the auto formatter

I'll provide instructions you can follow to configure both these things to use your preferred number of spaces:

Editor

The editor behavior can be configured in Arduino IDE's advanced settings:

  1. Press the Ctrl+Shift+P keyboard shortcut (Command+Shift+P for macOS users) to open the "Command Palette".
    A menu will appear on the editor toolbar:
  2. Select the "Preferences: Open Settings (UI)" command from the menu.
    You can scroll down through the list of commands to find it or type the name in the field.
    A "Preferences" tab will open in the Arduino IDE main panel.
  3. Type editor.tabSize in the "Search Settings" field of the "Preferences" tab.
  4. Set the field under the "Editor: Tab Size" setting to your preferred number of spaces.
  5. Close the Preferences tab by clicking its X icon.

Auto Format

The sketch code can be automatically formatted to a standardized style by selecting Tools > Auto Format from the Arduino IDE menus. It is possible to define a custom formatter configuration.

The configuration system is documented in general here:

https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-customize-auto-formatter

The standardized formatter configuration file is available from the link in that tutorial. If you would like the formatter to use a different number of spaces, use that file, but change the value of the relevant properties.

For example, if you want an indent of 8 spaces, change this line:

IndentWidth: 2

To this:

IndentWidth: 8

Wow Thanks!

They couldn't have made that more difficult if they tried!!

The instructions under the "Auto Format" section are only required due to a bug in Arduino IDE:

Once that is fixed, the formatter will be automatically configured when you change the "Editor: Tab Size " setting.

If you have a GitHub account, you can subscribe to that issue to get notifications of any new developments related to this subject.