Hello Ashley, All,
First, I'd like to thank you all for the suggestions and recommendations. Your feedback is valuable for us and for mbed as development ecosystem, and it's great that you take time to express it.
Often there are conflicting suggestions and feedback, especially when they based on subjective preference, rather than practical reasons. The coding style is one of them.
Most of the developers use 4 spaces for indentation, hence it's the default indentation value in majority of editors/IDEs. Some developers prefer 3 spaces indentation, others 2, and some even 8 spaces, and usually there is an option for that in most offline IDEs to control that. The mbed Online IDE aims provide a standard "out-of-the-box" experience for everyone and given its tightly collaborative nature, it has the difficult task to set a standard not just for the individuals, but also for developer groups and literally everyone.
Deviating from this can have undesirable effects, like repository commits that are mix between coding style and functionality changes, caused by different "auto-format" behaviors due to different style settings in the IDE. Imagine a situation where for example Ashley has his mbed IDE set to indent with 3 spaces and he imports a random project that uses 4 spaces. Every code block that he writes will be indented to 3 spaces due to his settings, and that won't match the formatting of the existing source code. Basically he would have two options:
- change his settings to use 4 spaces width and re-indent the code that he added/changed
- re-indent the whole file by using the auto-format function, creating commit/diff havoc
If the code style differences increase over time, this could lead to everyone always clicking the auto-format button as soon as they start working on someone else's code... That will impact mbed as a whole and I won't be surprised if people begin forking code just to have the program/libraries indented to their own style.
The overall goal of mbed was always to improve productivity of embedded software development. One of the many ways we try and do that is to encourage a consistent style across all code, the style which is set by the auto-format code button. This doesn't mean we stop anyone from using their own style, but rather provide an automated functionality for the ones used to the K&R style.
As for not providing an official response, you can find an official response by Simon Ford on the following link: https://mbed.org/forum/bugs-suggestions/topic/2929/
On a side note, the aforementioned colorization options are already in our to-do list, but currently I can't tie a time frame to that.
Cheers,
Mihail
Hey guys!
The "Format Code" Function is cool, but the style is not what I like to see. For example I would write the Hello World example as this:
It would be great to have a global "Format-File" (or for each project). This could contain some Source Snippets you can format like you want. Here an example
Standard
I for example would change it to