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
- Get http://www.drchip.org/astronaut/vim/vbafiles/amsmath.vba.gz from Dr. Chip
- 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 %).
- 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.
~/.vim/syntax/tex.vim(assuming you have a Unix-like system, I don't know what it's called on Windows)? The math-mode syntax is in theMath Zonessections. It's probably simplest to search the file for an environment name that you know does work (such asdisplaymathorequation) and add similar entries foralign. (You might be able to get more help at https://vi.stackexchange.com/) – Nicola Talbot Feb 19 '18 at 13:04@NicolaTalbot Thanks for the suggestion. I don't have my own syntax file, but one is located in /usr/share/vim/syntax/tex.vim. What confuses me is this: "align" is already defined as a math zone in the syntax file, and I see no significant differences between the code in the syntax file involving "equation" and that involving "align." Yet "equation" actually gets highlighted correctly while "align" doesn't. What could be happening?
– Henry Wang Feb 19 '18 at 19:23tex.vimfile have any version details at the start of it? I think there are varioustex.vimfiles around. Maybe you have a different one to me. Mine is dated Jun 24, 2013 version 79 with the URL http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX – Nicola Talbot Feb 19 '18 at 20:11tex.vimfile contains the lines" Last Change: Jun 11, 2015and" Version: 87. – Henry Wang Feb 19 '18 at 21:54