How can vim reformat `gq` so as not to touch verbatim TeX sections?

In a LaTeX file I have several sections verbatim

scattered all over the place.

When I want to reformat an entire document, I usually use gq

. The problem is that this command also collects contiguous lines of verbatim sections. I don't want to gq

reformat my verbatim sections!

Before reformatting:

This is the
line I want to reformat because is spans on two lines and the
first does not fill to the right.

\begin{verbatim}
$ command1
$ command2
\end{verbatim}

      

After formatting:

This is the line I want to reformat because is spans
on two lines and the first does not fill to the right.

\begin{verbatim} $ command1 $ command2 \end{verbatim}

      

Is there another command for clever TeX reformatting in vim?

+3


source to share


1 answer


I usually use gq}

to just reformat the rest of the paragraph. I suspect it is impossible to do what you want without writing / using a script.



LaTeX Box does not advertise this feature, but should anyone implement it for the script to be the natural home for this feature.

+1


source







All Articles