5

I have the following definitions in a .tex file preamble:

\newcommand{\beq}{\begin{eqnarray}}
\newcommand{\eeq}{\end{eqnarray}}

If I then use \beq and \eeq to define an equation array region, spell checking is turned on in this region, where it would not be if I had used \begin{eqnarray} and \end{eqnarray}. I tried to turn off spell-checking in these custom regions using the method presented here, i.e. copy the $VIMRUNTIME/syntax/tex.vim file to ~/.vim/syntax and edit the file. I added a line like

syn region texZone start="\\beq" end="\\eeq\|%stopzone\>" contains=@NoSpell

to the file, but it didn't work, and spellchecking is not disabled between \beq and \eeq tags. I am very unfamiliar with Vim syntax files, so I don't know how to debug this or take further steps. Any thoughts on how to turn off spell check just in my custom region would be appreciated.

  • I'm curious, why would you want that macro in the first place? – Karl Yngve Lervåg Jun 4 '16 at 15:24
  • Just to make it faster to create an equation array environment since I use that a lot. I'm trying out Snipmate now though, and I think that will be a way more useful way to speed things up once I get it figured out. – Ben Lindsay Jun 4 '16 at 16:48
  • Ok, I see. IMHO, this is not a very good idea. It makes your LaTeX very dependable on the preamble for trivial reasons. I would also suggest that you read this: You should avoid the eqnarray environment alltogether, instead use the align environment. – Karl Yngve Lervåg Jun 6 '16 at 12:35
4

By placing that line by itself in ~/.vim/after/syntax/tex.vim instead of adding it to a copy of $VIMRUNTIME/syntax/tex.vim in ~/.vim/syntax/tex.vim, the spell checking behavior was disabled between \beq and \eeq tags as I wanted. Unfortunately, this line doesn't tell Vim it's a math region, so math syntax highlighting is different between these tags than it is between \begin{eqnarray} and \end{eqnarray} tags.

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.