I want to be able to use the gq
key combination in Vim to format the text in my Beamer LaTeX slides.
For example, I'd like gqap
to transform this:
\begin{frame}{Some title}
\begin{itemize}\item first point
\item second point
\item etc. point \end{itemize} \end{frame}
into this:
\begin{frame}{Some title}
\begin{itemize}
\item first point
\item second point
\item etc. point
\end{itemize}
\end{frame}
Specifically, I'd like to observe the following rules:
\item
always begins on a new line\begin
and\end
always begin on a new line\begin{frame}
and\end{frame}
always start in column 1- environments within environments are indented 2 spaces
\item
is indented 2 spaces within its environment
Thus, my core question relates to how the above could be achieved.
Alternatively, any suggestions on starting points or useful tutorials would be most helpful.
I'd also be interested in any comments about the relative merits of formatexpr
, formatprg
, or internal formatting for performing such formatting.