- I have a large code base with indentation that is very inconsistent.
- I finally got some buy in from developers for running a code formatter.
- I would like to start with just fixing the indentation because indentation is a lighter touch than running clang-format with a style.
- I like correcting indentation only because when you do the indentation only and then run
git diff --ignore-space-at-eol --ignore-space-change --ignore-all-spaceyou get zero diff lines.
- I like correcting indentation only because when you do the indentation only and then run
I want to avoid a situation where the formatted code is somehow worse and so people avoid any future attempts at making our codebase better via something like clang-format. In our case at least we can agree on spaces-only, tabs are 4-spaces. So improving only the indentation can only be a good thing.
Eclipse has a feature to "correct indentation" (via Menu --> Source --> Correct Indentation):
- Correct Indentation
- Applies simple indentation rules to the current selection, or the line containing the cursor, if there is no selection
- Ctrl+I
Eclipse's "Correct Indentation" does just the indentation but it is not a shell command and i want/need a shell command so that I can run the command on all the source code files.
Is there a way to use clang-format to do "indentation only"? if yes, how?
For example with space-only, 4-spaces.