Skip to main content
Microstar
Associate III
March 27, 2018
Question

STM32Cube indent using 2 spaces, How can I change it to 4 spaces?

  • March 27, 2018
  • 14 replies
  • 9354 views
Posted on March 27, 2018 at 05:29

exp:

void function(void) {

  int cubemode;

}

void function(void) {

    int iexpect;

}

#indent
    This topic has been closed for replies.

    14 replies

    Mich1
    Associate III
    January 18, 2019

    I hope it will be done one day

    nguyennhantinh
    Explorer
    June 15, 2019

    Replace '#t' by '#t#t' all file in "Program Files \STMicroelectronics\STM32Cube\STM32CubeMX\db\templates"

    Mich1
    Associate III
    June 20, 2019

    we can see in these files:

    [#if nTab==2]#t#t[#else]#t[/#if]

    Could it be possible to define nTab somewhere?

    Microstar
    MicrostarAuthor
    Associate III
    July 4, 2019

    This may be a simpler way. I‘ll try.

    WWawr
    Associate
    July 17, 2019

    I used a PowerShell command for this:

    (With Administrator privileges) here C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeMX\db\templates>

    Get-ChildItem *.ftl -Recurse | ForEach { (Get-Content $_ | ForEach { $_ -replace 'nTab=1', 'nTab=2' }) | Set-Content $_ }

    Seems to work

    StefanRickli
    Associate
    November 1, 2019

    This hasn't been addressed yet, or has it?

    Edimahler
    Associate II
    April 1, 2020

    Same question here. Would be a really tiny work for ST to finally implement this and would save us hours of "redesigning" the code every time again, when creating a new project.

    Edimahler
    Associate II
    April 1, 2020

    BTW: Does anybody knows, where to find the template files of CubeIDE in order to edit them using the Powershell way mentioned above?

    BDinh.1
    Associate
    July 20, 2020

    Here is my instructions, worked well for me,

    # find your STM32CubeMX.jar, make backup if necessary
    find /opt/st/stm32cubeide STM32CubeMX.jar
     
    # copy to temporary directory
    cp STM32CubeMX.jar /tmp/test
     
    # download Java Jar explorer and decompiler
    https://github.com/Col-E/Recaf
    # use recaf to navigate to com/st/microxplorer/codegenerator/CodeEngine.class
    search for replace("#t", " "), right click to the containing function "cleanCode", find for string " ", change to " "
     
    # save the new jar file by File > Export Program
    # close recaf, double check by reopen new jar file and confirm #t is now 4 spaces.
     
    # restore new STM32CubeMX.jar to the original location

    BDinh.1
    Associate
    July 23, 2020

    Check out my pre-patched cubemx here:

    https://github.com/jetacpp/stm32cube_patch.git

    NRatz.2
    Associate II
    August 25, 2022

    Found it. In Windows > Preferences > General > Editors > Text Editors

    Check "Insert spaces for tabs"

    DBart.12
    Visitor II
    April 19, 2023

    Hey, ST, any way to add a simple option in CubeMX to toggle that?