可以在STM32CubeIDE中手动触发自动源代码格式化吗?

Possible to manually trigger automatic source code formatting in STM32CubeIDE?

我使用 STM32CubeIDE 1.6.1 版,并注意到 CubeMX 输出格式化代码(例如缩进 2 个空格)。我想手动重新应用此源代码格式(即手动触发所选文件的源代码格式)。

我找到了这个 post: https://www.openstm32.org/forumthread6435 ,其中提到:

go the preferences dialog and select C/C++ > Code Style > Formatter
click on “Edit...” change the tab size field. close the preferences

Then, select all the project you want to apply it, click right and select “Source > Format”

所以,我不是 100% 确定上面的引用是指 STM32CubeIDE,但是,第一部分仍然存在,在 Window/Preferences 我可以得到这个:

但是,我看不到如何在选定文件上手动触发此源代码格式设置。例如,https://dvteclipse.com/documentation/e/Format_Multiple_Files.html for Eclipse(STM32CubeIDE 是基于 Eclipse 构建的)提到通过右键单击源文件,可以调用命令“Format Source Files”;然而,当我在 STM32CubeIDE Project Explorer 中单击我的 main.c 时,我看不到类似的东西:

那么,有没有办法在 STM32CubeIDE 中手动触发选定(单个或多个)源代码文件的自动源代码格式化?

终于明白了 - 当您在 STM32CubeIDE 的 Project Explorer 中 right-click Core 节点或其任何 children 时,您会在 right-click上下文菜单,里面只有一个child,"Format":