Pls, do not change the places of comments in Auto Format

Tnx for the update.

  1. Slow opening IDE. There is a change about the previous version, but it is slооow!
  2. Pls, do not change the places of comments in Auto Format. Or let there be a choice for both options in the main preferences. Sometimes we have a whole letter in comments, pseudo-drawn wiring electric diagrams, etc. similar. After Auto Format they become unusable, but Auto Format is a useful and often used function.
1 Like

Hi @rockn

If you would like to customize the behavior of Auto Format, the instructions are here:

It is not clear to me what the specific problem is, but if you are having problems with auto format changing the formatting of your comments, it should be easily solved by simply adopting the code style of the standard Auto Format when you are writing the comments. If you do that, there will not be any changes to the comments when you do an Auto Format operation.

For the front post:


Why does the IDE remember where (on which line) I closed the file. At first glance: great. But I have about 5000 projects on the disk, some of them are more than 5 years old. To see my description at the beginning of the program, I have to scroll all the time after opening. (What I wrote 2 post was after discovering the difference from v1.8.19. From version etc. 1.6.5 it was still like that. It's changing now.).

The comment looks fine. Is this before or after the auto format?

It only takes a second to do if you use the Ctrl+Home keyboard shortcut

Before :).
Then it gets messy. All for old projects.


We have to change our habits :). If there is another choice, I would prefer the first.

Please post an example of a comment that would be damaged by auto formatting with the standard configuration. Post it as code, not as a screenshot.

The vision of code is not a problem, it can be messy. I'm v1.8.19 user. I will not use v2 in future. There are too many inaccuracies in the interface. That's why I don't use "big products" - In the complexities. The Arduino (and Arduino IDE) is nice because it was simple! But in v2 i see regression. That's why I'm writing here - because Arduino is my favorite product! :slight_smile:

A little while ago: error in the board. It forgets the previous setting. No real device ... Trial and errors, and free time is spent in settings, not in writing favorite code :slight_smile: .

at24c02.zip (1.9 KB)

Feedback is welcome, but super vague feedback is not of any value.

If you found a problem, take the time to write a detailed report.

Provide easy to follow instructions for a complete, minimal demonstration of the problem.

Keep in mind that those you submit the report to are not mind readers. Review your report carefully from the perspective of someone who only possesses the information provided in the report. If it is not clear from that perspective, add more information until it is.

If you look at the posts in this section of the forum, I think you'll see that many of the actionable reports have already been resolved. It might take a little time, but it is an effective way to make this important tool better.

Too vague. If I can't reproduce the problem, I can't do anything about it.

I did an auto format of that sketch and didn't notice any problems at all.

Do Auto Format for at24c02.cpp.

There is no problem with the code. The problem is with the vision: it changes what has been there for like 7 years in all other older versions. The problem is that the comments get mixed up from v2 onwards.

Tnx, we'll get used to it. Or, like me, we'll stick to the old versions of the IDE.

OK, well if you are happy with things as they are then I guess the conversation is concluded.

Best wishes,
Per

Isn't that a little hard? Is a UI an option for this?

I don't think so. Customizing the formatter is something only advanced users need to do. Most users will be happy with the official Arduino code style.

It was necessary to edit a text file to customize the Arduino IDE 1.x formatter as well, so this is no different than what we had before. The configuration capability is more powerful in Arduino IDE 2.x because in addition to the global configuration we always had, it is now possible to also set per-sketch configurations. This can be very useful when collaborating with others on a sketch project because it ensures all contributors will use a consistent code style.

Some options are available in the advanced settings, such as the indentation size and whether to use tabs or spaces. You can learn how to adjust the advanced settings here:

https://github.com/arduino/arduino-ide/blob/main/docs/advanced-usage.md#advanced-settings

The auto format is designed to use those settings, but there is currently a bug in that system which causes them to not take effect:

It should be an easy fix, so I'm sure that will be resolved before too long (sooner than that if the community submits a fix :smiley: )

Beyond that, I don't see any point. Best practices is for the community to use a single standardized code style rather than fragmenting into a zillion different code styles. True professionals understand that the important thing when it comes to code formatting is consistency, not the specific style.

from the previous post from @rockn about messing with comments, it seems you broke the consistency you had for years. I thought that was his point.

I went to great lengths to reduce the impact of the change from using the Artistic Style code formatter to ClangFormat made during the transition from Arduino IDE 1.x to 2.x, as well as to set up an automated validation system that will allow us to avoid any further changes while updating to new versions of ClangFormat

I would never intentionally change the formatting because I care very much about consistency.

I also repeatedly offered the community the opportunity to contribute any further impact reductions I might have missed.

The remaining changes were impossible to avoid.

I also pushed for the custom configuration capability to mitigate those changes. I was planning to investigate whether I could find a custom configuration that might meet @rockn's requirements, but that wasn't possible because I was unable to determine what those requirements might be

Don't change comment spaces (reduce the spaces before the comment to 2) (оr make an option "not to do" in preferences (old_stile Auto Format).

To protect the writing and share how important it is to me: since several years I have been writing about PIC, thanks to the rules in the Arduino IDE (up to v1.8.19) the last auto-format for the current controller (and its IDE) I paste in the Arduino IDE and save the final project. This was the best from this IDE - Auto formatting.

I'm so used to (and it's beautiful) the arrangement. I like the spacing of 2 spaces etc. small, but useful blessings, thought out in advance. And now everything must disappear.That's why I say I'm sorry. But if I have to, I'll part with the Arduino IDE (maybe with Arduino too :frowning: ).

(I use partial google EN translate, >7 years Arduino-user)

If I understand your problem correctly, there is a solution. The problem is about e.g. the below line, correct?

  m_chip_addr = _i2c_addr;                                  // I2C адрес на EEPROM

which changes to

  m_chip_addr = _i2c_addr;  // I2C адрес на EEPROM

The relevant links copied from topic Clang setup; where is .clang-format, post #2,

  1. The configuration used by the IDE: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/other/clang-format-configuration/.clang-format
  2. Link to the documentation: Clang-Format Style Options — Clang 14.0.0 documentation

If you haven't created a .clang-format file yet, that is the first step. Use link (1) and copy it; paste it in a decent editor and save it in C:\Users\yourUsername\.arduinoIDE with the name .clang-format (no extensions, literaly like that). This will be the global configuration file for the autoformater.

image

In the file, find the line SpacesBeforeTrailingComments: 2 and change the 2 to -1. Save the file.

Unfortunately the value -1 is undocumented in link (2) for the above option. So the behaviour might change in the future; there are however a few numeric settings that allow -1 to indicate that something should not change and that is what I based the solution on.

In the IDE, apply the autoformat to your sketch or file. Note that you can make changes to the clang-format file on the fly; no need to open/close the IDE.

sterretje, tnx. With the patch: .clang-format, SpacesBeforeTrailingComments: -> -1 AutoFormat does nothing. The idea was: auto-format as in version v1.8.19. Otherwise, there is no point in using it.

Something else may have come with the file. This is very complicated for me to change in a text editor file! The probability of a mistake is huge. (I'm an amateur)

do you have an example of where the -1 does not do what you want compared to IDE 1.8.19 ?

v1.8.19 before Auto Format:

v1.8.19 after Auto Format:

v2.0.1 before Auto Format:

v2.0.1 after Auto Format:

Another setting that might be relevant is AlignTrailingComments:

https://releases.llvm.org/14.0.0/tools/clang/docs/ClangFormatStyleOptions.html#:~:text=AlignTrailingComments