This question already has an answer here:
- Autoindent in Texmaker? 3 answers
Is it possible to indent in texstudio based on the levels? It seems that a proper macro might be able to do such a job, though it seems to be complicated.
Thanks to Troy, we know that latexindent has this capacity.Therefore the problem is to write a macro which runs the latexindent on all file at once without causing problems.