How can I make the IDE 2.0 use tabulations instead of spaces?

I was searching for a way to do this, and I found nothing. The only related thread is this:

But it's only relevant for the IDE 1.0

Hi @thepirate42. As with Arduino IDE 1.x, 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 so that tabs will be used for indentation instead 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.insertSpaces in the "Search Settings" field of the "Preferences" tab.
  4. Uncheck the box under the "Editor: Insert Spaces" setting.
  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 tabs for indentation, use that file, but change this line:

UseTab: Never

To this:

UseTab: ForIndentation
3 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.