Add .clang-format file to icu4c source to unify the style among icu4c
In order to unify the coding style of icu4c, I suggest adding .clang-format file that includes all the formatting styles that we agreed on for icu4c. Thus will help us to format our files easily by running clang-format tool.
There is a commit on this ticket shipping in ICU 68. Should the ticket be marked as fixed?
“AllowShortBlocksOnASingleLine” is the option I’m most often going against - we’ve got it set to “SBS_Always”, I think we should at least consider whether we’d prefer “SBS_Empty” - particularly if we’ll encourage anyone to trust autoformatting (e.g. via git-clang-format).
The other thing I’m not trusting clang-format to take care of is documentation wrapping. We’ve got “ColumnLimit” set to 105, but I really strongly prefer documentation to be wrapped at 80 characters at most: easier to fit two code windows side-by-side and not have to scroll left/right in order to read. (Narrow columns are also easier to read, e.g. newspapers.)
Unfortunately I don’t see clang-format supporting different wrapping widths for code as for documentation. I’m wrapping docs with VSCode’s “rewrap” extension instead of letting clang-format take care of it.
Looks like git-clang-format can automatically format only changed code. We could document this as a suggested workflow for those interested. I’ve commented about this on Younies' pull request too:
Codingguidelines also found in the userguide-migration branch in the ICU repository:
I guess any improvements go direclty here, userguide on Google Sites is now considered read-only AFAIR.