3

I use pandoc a lot which means that I write with a mix of markdown and latex a lot. The problem is that I can't make Vim highlight Latex as it should, even though pandoc understands it.

For example, the following snipet

# Header 1

Variable $x_0$ is defined as
\begin{align}
x_0=y_0^2
\end{align}

If I name it test.md Vim only sees markdown and fails to highlight $x_0$ and the align environment. I can make the situation a little bit better if I follow this answer then I can at least make the $ $ highlighted.

As a quick workaround I found that by naming the file with a .Rmd extension I get the $ $ to work, although that isn't strictly correct I guess.

But so far I have not been able to get both Markdown Syntax and Latex syntax simultaneously. Is there a way that can be done?

PS: I'm really trying to avoid installing obscure Vim plugins that need Vundle etc in the name of portability!

TomCho
  • 3,204
  • 6
  • 32
  • 83
  • 1
    I'm not sure you're going to get something that complex without a plugin, and Vim does not include a LaTeX plugin (nor does its Markdown plugin seem to understand LaTeX math). I would suggest you look at https://github.com/plasticboy/vim-markdown for this. – Dan Lowe Jul 16 '17 at 02:36

1 Answers1

4

The work around I found (almost by accident) was to copy this file, which is a syntax file for Pandoc, into ftplugin and add these lines to vimrc

augroup pandoc_syntax
    au! BufNewFile,BufFilePre,BufRead *.md set filetype=markdown.pandoc
augroup END

This is actually part of a plugin. But I found that this way is much simpler than having the whole plugin installed and much more portable.

TomCho
  • 3,204
  • 6
  • 32
  • 83