cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeIDE Indentation and Generate Code

hardrock
Associate III

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.

10 REPLIES 10
Mikk Leini
Senior

I am also hoping to see the solution to this feature request, but since there's confusion in the follow-up replies, I would like to specify that IMHO only the user-modifiable project files should have user-configurable indentation style and it should be all across the file - even outside user editable sections. Such files are under Core folder and different Middlewares "glue code" folders. Library files, like HAL, CMSIS, Middleware, can keep their original style.

If generator gets the indentation style from Eclipse code style settings then that's perfect, but if there are indentation character and indentation space count configuration option in CubeMX window (e.g. Project manager -> Code generator), then that's fine also.

This is obviously not a showstopper feature, but for developers who appreciate aesthetics it causes itchy feeling and for developers who occasionally use automatic code formatting, it can create unwanted code differences since white spaces change back and forth.