This question already has an answer here:

Sometimes, I find it a bit hard to manually indent my code so that all the \begin{...}'s and \end{...}'s align vertically in my .tex source code. In some code development environments, I know that there are options to auto-indent the beginnings and ends of loops, functions, and other code blocks. I'm wondering if there is a way to do this in TeXShop or any other freeware for latex code?

marked as duplicate by Joseph Wright Aug 10 '13 at 9:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.