I use vim to edit latex files and the automatic formatting option (formatoptions+=a
) works very well, since you can enter text anywhere in the paragraph and vim will reformat the entire paragraph.
The problem is that when I edit a set of lines containing commands, like this
\begin{enumerate}
\item Apple
\item Banana
\end{enumerate}
vim treats the text as though it were a paragraph, and will reformat to this
\begin{enumerate} \item Apple \item Pear \end{enumerate}
I am wondering if there is a way to automatically reformat prose only. A solution specific to latex might just ignore lines beginning with \
but perhaps there is a smart general solution involving some vim settings.