Skip to content

Autoformat should remove spaces after (if, while, switch) statement conditional #10326

Closed
@Avamander

Description

@Avamander

For example when the code looks like this:

if (a != b)          {
  return;
}

it should be turned into:

if (a != b) {
  return;
}

Same applies to switches:

switch (character)          {

it should be turned into:

switch (character) {

Activity

per1234

per1234 commented on Jun 10, 2020

@per1234
Collaborator

Arduino uses Artistic Style for auto formatting:
https://sourceforge.net/projects/astyle/
From what I can see, it does not currently have this capability. So I think the best way to proceed would be for you to make the feature request to the AStyle developers. Once the Artistic Style developers have added the feature, you'd then need to petition Arduino to update the version of AStyle they are using.

Avamander

Avamander commented on Jun 10, 2020

@Avamander
ContributorAuthor

I opened an Astyle feature request: https://sourceforge.net/p/astyle/tickets/123/

added
Upstream notifiedRelated to a software component maintained by someone else. They have been notified of it
on Jun 12, 2020
fabianoriccardi

fabianoriccardi commented on Mar 25, 2021

@fabianoriccardi

Do you know if Astyle is abandoned? I have looked at the repo but I don't see any activity in the past 2 years...

fabianoriccardi

fabianoriccardi commented on Mar 30, 2021

@fabianoriccardi

Sadly, the answer.

per1234

per1234 commented on May 25, 2021

@per1234
Collaborator

Hi @Avamander thanks for your interest in improving the code formatting capabilities of the IDE!

There is some good news related to this feature request. #11543 will change the Arduino IDE from using the Artistic Style formatter to ClangFormat, which provides just the sort of behavior you requested here.

ClangFormat is very popular and actively developed, and even suggested by the Artistic Style developer at the post @fabiuz7 kindly shared.this statement where they state that they are no longer able to play as active a role in developing Artistic Style.

You can give the test build for the ClangFormat/Arduino IDE integration a try. The downloads are available here:
#11543 (comment)
If you do try it out, please let us know how it goes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Upstream notifiedRelated to a software component maintained by someone else. They have been notified of itfeature requestA request to make an enhancement (not a bug fix)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Autoformat should remove spaces after (if, while, switch) statement conditional · Issue #10326 · arduino/Arduino