Autoformat quirk?

When I use the IDE 2.3.7 Autoformat tool on a sketch containing lines over 80 chars in length it gives the unwanted result of splitting it into two lines.

These two examples get split:

#define button 2 // this is 81 chars long this is 81 chars longxxxxxxxxxxxxx12345
const int xyz = 0; // this is 81 chars long this is 81 chars longxxxxxxxxxxx12345

But these two don't:

#define button 2 // this is 80 chars long this is 80 chars longxxxxxxxxxxxxx1234
const int xyz = 0; // this is 80 chars long this is 80 chars longxxxxxxxxxxx1234

Splits look like this:

#define button \
  2 // this is 81 chars long this is 81 chars longxxxxxxxxxxxxx12345

const int xyz =
    0; // this is 81 chars long this is 81 chars longxxxxxxxxxxx12345

Probably because screen width historically is 80 wide.

Any line over 80 most likely needs to be seriously looked at and shortened if possible in any case.

Hi @Terrypin !

Using this version

Version: 2.3.7
Date: 2025-12-17T16:05:25.389Z
CLI Version: 1.3.1
Copyright © 2026 Arduino SA

on Windows 11

I could not reproduce the behaviour. What I did:

  • Create a new sketch
  • Copy the upper code lines into the sketch
  • Formatted the code by either Alt-Shift-F or Ctrl-T or Popup menu

I also added characters to the lines (100 characters per line) but they did not split. The same applied after narrowing and restoring the window width.

It might be a configuration issue or OS dependend?

You may check your auto-formatter configuration file, see here
https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-customize-auto-formatter/

An entry of "ColumnLimit: 0" in the .clang-format file should switch off the automatic line wrapping. I'm not sure if this is the source of your problem but you could give it a try ...

Good luck!
ec2021

1 Like

Thanks! That did indeed prove to be the culprit. Intuitively I'd have expected

ColumnLimit: 80

or whatever, but pleased to get it fixed.

@sonofcy
I do my own splitting (actually into a few chars less than an IBM 80-col card), so that I can read longish comments with wor
ds intact.
:slightly_smiling_face:

You could also use block comments. I use very few, and if I have to look at someone else's code, I delete them all, as they are almost always not kept up to date with the code and are just misleading. Well-written code is self-documenting.

Then I'm guessing you were already using a custom formatter configuration.

The reason is that Arduino IDE's built-in formatter configuration already has this:

Note that if you use a custom ClangFormat configuration file, it is used instead of the built-in configuration file. If you don't define a given configuration key in your custom config file, ClangFormat will use whatever is the default value for that option (which will depend on the value of the BasedOnStyle key in your configuration file). For this reason, I would recommend defining all available format options in your custom configuration file, even in the case where you currently find the default to be fine. The official Arduino ClangFormat configuration can be used as a good starting point for that, as it does define all options:

https://raw.githubusercontent.com/arduino/tooling-project-assets/main/other/clang-format-configuration/.clang-format

1 Like

Thanks, you’re right, I did have that. I’ll implement your recommendations , although that’s a lot of settings!