I want to introduce clang-formatter to our company, but there are some restrictions, like:
Some files in our company that are better read with a tab-width=2 while others are better read with tab-width=4.
This means that some files (due to the nature of their content) should have a different .clang-format configuration file. So, assumming that we end up with 2 or 3 configurations, suitable for each content, is there a way that I can force some files to be formatted by a particular .clang_format ?
for example,
- could this be done by placing a different .clang_format in each folder ?
or
- by entering the YAML lines as comments at the beginning of each file (like doxygen) ?
we use C, C++, visual studio and vim
You can place a different .clang-format (_clang-format) file into each directory. clang-format will start looking for it in the file's directory and then search through all its parents until it finds one (assuming you are setting -style=file).
This sounds like it would solve your use case. If not, I'd like to understand how. Do you have files in the same directory that need different indentation?