2

I made some custom commands to make writing equation blocks easier:

% Equation starters
\newcommand{\eqn}[1]{\begin{equation} #1 \end{equation}}
\newcommand{\eqns}[1]{\begin{equation*} #1 \end{equation*}}
\newcommand{\eqna}[1]{\begin{align} #1 \end{align}}
\newcommand{\eqnas}[1]{\begin{align*} #1 \end{align*}}

This is so that

\begin{equation}
    e^{i \tau} = 1
\end{equation}

gets simplified to

\eqn{
    e^{i \tau} = 1
}

In the second line, the syntax highlighting inside the \eqn{} block is wrong, because vim doesn't realise it's maths. Now, I just need to tell vim what I have done. I have no idea how, though.

2

I eventually figured it out. I customised the syntax with a one-liner in my .vimrc that looks like this:

" Add custom equation delimiters to syntax highlighting.
au FileType tex syn region texMathZoneZ matchgroup=texStatement start="\\eqn{"  start="\\eqns{" start="\\eqna{" start="\\eqnas{"    matchgroup=texStatement end="}" end="%stopzone\>"   contains=@texMathZoneGroup

Works like a charm!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.