2024-04-29 01:40 AM
Whenever I generate code, the indentation is always 2 characters.
Even though the indentation is set to 4 characters in the settings,
it continues to be generated as 2 characters except for the user code.
Formatter > Indentation
Tab Policy : Spaces Only
Indentation Size : 4
Tab Size : 4
I always repeat the below actions after generating the code.
main.c > Select All (Ctrl+A) > Correct Indentation (Ctrl+I)
I always use 4 characters indentation in my S/W design.
but it is quite inconvenient.
and I would like to ask if there is any room for improvement this.
2024-04-29 01:49 AM - edited 2024-04-29 01:51 AM
Hi,
what you set in (right click in text area )-> preferences ?
I have :
and in text editors ->
--> makes 4 char indentation ->
2024-04-29 02:30 AM
Thank you for your reply.
I still have the problem.
The code is always generated 2 characters indentation except user code.
2024-04-29 02:47 AM
So, just to be clear, you're saying that the editor observes your settings for what you type, but the CubeMX generator does not observe them for the code it auto-generated?
2024-04-29 02:50 AM
To understand you : you want the HAL lib changed to another style , than it is, or
the code generator generate a different code style in the "not-for-user" generated code areas ?
+
When you write your program - in "user code area" - its doing, as you want /set it ?
2024-04-29 04:36 AM
Thank you for your reply.
The CubeIDE generator creates that "user code" is 4-chars indentation based on settings,
but "non-user code" is 2-chars indentation automatically.
The indentation is mixed between 2 or 4 chars in one file, it makes difficult to see.
I want that both "user code" and "non-user code" are generated together
with N-chars indentation according to user's settings.
2024-04-29 04:51 AM
@hardrock wrote:The CubeIDE generator creates that "user code" is 4-chars indentation based on settings,
Not sure what you mean by that?
CubeIDE/MX doesn't generate any User Code; it's called "User Code" because it's created by the User - you!
CubeIDE/MX puts comments to indicate where you can safely enter your "User Code" - but it doesn't generate any of that code.
2024-04-29 05:14 AM
I understand what you are saying.
The "user code" (my code) can be adjusted the indentation according to my settings.
But how to adjust the indentation of "non-user code".
The indentation of "non-user code" is always 2 chars as default.
2024-04-29 05:33 AM
As @AScha.3 said, it would need to be a lot more than just the indent step:
Probably best is to put it through a code formatter - aka "beautifier" or "prettifier" - configured to your particular tastes...
And/or keep your code out of the auto-generated files - so you don't have to look at it!
2024-04-29 11:55 AM
Since the Cube thing is integrated into CubeIDE, the code generation should get the formatting options from Eclipse. This looks reasonable.