How do I make vim highlight math properly in the align environment?

How do I make vim highlight math properly in the align environment?

Sorry if this is the wrong place to ask this, I'm new to the site :/

My issue is this: when editing in vim, my syntax file highlights underscores and carets when found in non-math text, which is fine, except vim doesn't recognize that "align" is a math environment. What do I need to do to fix this?

how do I fix this??

답변1

Sometime around 2017 (I think), Dr. Chip decided that base-vim should only support syntax highlighting for base-latex. It is necessary to add in support for syntax highlighting for things available in latex packages (such as amsmath, which is what provides the align environment).

But this is very easy, and Dr. Chip includes syntax files for amsmath (and a few other packages) on his website.

In order to use these, you do the following. I will assume that you want to install additional highlighting to cover the align environment. As this comes from amsmath, we will add additional amsmath highlighting support. Then you

  1. Get http://www.drchip.org/astronaut/vim/vbafiles/amsmath.vba.gz from Dr. Chip
  2. The file is in vimball format, and the easiest way to extract it is to open it with vim and follow instructions (which probably say :so %).
  3. Move and rename amsmath.vba to ~/.vim/after/syntax/tex/amsmath.vim (or the corresponding location on your machine). One can also run :so % from amsmath.vba, this will automatically make ~/.vim/after/syntax/tex/amsmath.vim (and works if moving the amsmath.vba doesn't)

It is also possible to do this directly from your vimrc by making new "math zones" (and this is mostly what amsmath.vim does anyway). See :h tex-math for more.

관련 정보