Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert eclipse formating to .clang-format or use eclipse formatter in vscode

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?

like image 672
Robert Gałat Avatar asked Nov 06 '22 05:11

Robert Gałat


1 Answers

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).

like image 107
Robert Gałat Avatar answered Nov 13 '22 15:11

Robert Gałat