STM32CubeIDE – replace spaces by tabs

I wanted to configure STM32CubeIDE so that it replaces tab character by spaces, when editing source code. Easy, once one knows where to look:

  • select Window > Preferences
  • select C/C++ > Code Style > Formatter
  • create a new profile, based on the profile you prefer
  • in the Indentation tab, select Spaces only for Tab policy

If you have some existing source code using tabs, you can replace them by spaces by selecting whole file content (Ctrl-A) and correcting indentation (Ctrl-I).

As STM32CubeIDE is based on Eclipse CDT, the above process works for Eclipse CDT as well, of course.