cancel
Showing results for 
Search instead for 
Did you mean: 

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

Microstar
Associate III
Posted on March 27, 2018 at 05:29

exp:

void function(void) {

  int cubemode;

}

void function(void) {

    int iexpect;

}

#indent
14 REPLIES 14
Mich1
Associate III

I hope it will be done one day

nguyennhantinh
Associate

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

Mich1
Associate III

we can see in these files:

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

Could it be possible to define nTab somewhere?

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

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

I decide patch jar file, function cleanCode in CodeEngine.class,

    while ((line = inFtl.readLine()) != null) {
      String result = line.toString().replace("#n", "\r\n").replace("#t", "    ");
      writer.write(result + "\r\n");
    } 

modify constant u8 from two space to four, then repack it back to STM32CubeMX.jar

but some ftl file (usbd_cdc_if_c.ftl) ident is hard coded as two space instead #t so nTab hack takes no effect.

StefanRickli
Associate II

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

Could you explain how you did this?

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.