I want to change source formatting of if statements from the top example to the bottom example shown. I want the brackets to align with the if, i.e. same column..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-07-15 2:00 PM
if (SW1Pressed_F && (!SW1ActionTaken_F))
{
DesiredSpeed = 10;
DesiredDirection = LEFT;
}
if (SW1Pressed_F && (!SW1ActionTaken_F))
{
DesiredSpeed = 10;
DesiredDirection = LEFT;
}
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-07-19 4:13 AM
Formatting the source code can either be done by the editor, or many GUIs already contain it. The STM32CubeIDE, for example, is able to apply such formatting as an Eclipse variant with so-called profiles. Some profiles are already predefined, but you can also modify them and save or export them under your preferred name.
By the way, exporting a profile is very useful because you can import the exported profile into new installations with just a few clicks.
How to reach the Formatter:
- Windows > Preferences > C/C++ > Code Style > Formatter
or a little shorter:
- Windows > Preferences > [type filter text] --> formatt
Modify an existing profile:
- within the Formatter via New > [new profile name] + select the profile to be used as a template
- Adjusting the 65 million parameters (after that it is clear why Export is extremely useful)
- Export
- save with OK
Export:
- within the Formatter via Edit > Export
Perhaps my Kernighan&Richie-derived Quick'n'Dirty profile (attached) will be of interest to you and could serve as a template.
Regards
/Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-07-15 2:02 PM
Note that the forum messed up my columns in the example, but my statement is correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-07-15 2:04 PM
Trying again...
if (SW1Pressed_F && (!SW1ActionTaken_F))
{
DesiredSpeed = 10;
DesiredDirection = LEFT;
}
if (SW1Pressed_F && (!SW1ActionTaken_F))
{
DesiredSpeed = 10;
DesiredDirection = LEFT;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-07-15 2:05 PM
Nope, screwed it up again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-07-15 2:11 PM
You can a) Edit your posts see V icon in upper right corner of posting, b) use the code posting tool </> icon, or c) post a picture or bitmap mountain/sub icon
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-07-18 12:52 AM
Hello,
Something like this?
if (SW1Pressed_F && (!SW1ActionTaken_F))
{
DesiredSpeed = 10;
DesiredDirection = LEFT;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-07-18 9:31 AM
if (SW1Pressed_F && (!SW1ActionTaken_F)) { DesiredSpeed = 10; DesiredDirection = LEFT; }
1. if (SW1Pressed_F && (!SW1ActionTaken_F))
2. {
3.
4. DesiredSpeed = 10;
5.
6. DesiredDirection = LEFT;
7. }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-07-19 3:35 AM
Aren't there tools like Uncrustify that can apply any kind of formatting template you want?​
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-07-19 4:13 AM
Formatting the source code can either be done by the editor, or many GUIs already contain it. The STM32CubeIDE, for example, is able to apply such formatting as an Eclipse variant with so-called profiles. Some profiles are already predefined, but you can also modify them and save or export them under your preferred name.
By the way, exporting a profile is very useful because you can import the exported profile into new installations with just a few clicks.
How to reach the Formatter:
- Windows > Preferences > C/C++ > Code Style > Formatter
or a little shorter:
- Windows > Preferences > [type filter text] --> formatt
Modify an existing profile:
- within the Formatter via New > [new profile name] + select the profile to be used as a template
- Adjusting the 65 million parameters (after that it is clear why Export is extremely useful)
- Export
- save with OK
Export:
- within the Formatter via Edit > Export
Perhaps my Kernighan&Richie-derived Quick'n'Dirty profile (attached) will be of interest to you and could serve as a template.
Regards
/Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-07-20 9:42 AM
