问题
In my project (C/C++) I use slightly modified formatting from eclipse default formatter (bsd/allman + spaces over tabs).
I would like to switch the editor, and to do so, I have to have correct formatter.
Is there a way to convert .xml
file with formatting exported from eclipse, to .clang-format
file ?
I aim to have exactly the same formatting, and I do not want to reformat the project, just because I switched the editor
Optionally, is there a way to use eclipse formatter in vscode for C/C++ projects?
回答1:
I realized, that the project did not have checking of formatting in CI, and when I run any formatter it had massive changes, so In my organization, I forced everyone to adapt clang format, and I added checks to the CI.
This solved my issue, but during my investigation I found that not all options can be moved to other formatting tools (who would have thought), so changing formatter will almost always need some reformatting.
I found that it is possible to run eclipse formatter standalone (I don't have any reference, so if you are interested, than you need to look for it), I could not get this to work tho.
In summary if you can, avoid changing formatters because some options may not be available. And I would suggest using tools that can be easily used standalone (clang-format).
来源:https://stackoverflow.com/questions/63373842/convert-eclipse-formating-to-clang-format-or-use-eclipse-formatter-in-vscode