George
George

Reputation: 7317

Adding YAML syntax highlighting throughout an entire markdown file (in vim)

I currently have the plugin vim-markdown installed. Among other things, it adds syntax highlighting to markdown files. But frequently in markdown files there are yaml headers:

---
yaml: contents
more: yaml
---

# Usual markdown
Etc.

Using vim-markdown, the part of this file enclosed in --- is correctly rendered as yaml (from a syntax highlighting point of a view). The rest of the file is rendered as markdown.

Question: How do I make it so that, no matter where the enclosing --- are located -- yaml is rendered in between?

Attempt: I found in the ~/.vim/bundle/vim-markdown/syntax/markdown.vim the following snippet:

syn include @yamlTop syntax/yaml.vim
syn region Comment matchgroup=mkdDelimiter start="\%^---$" end="^---$" contains=@yamlTop

I removed the \% in the start= field and tried again. But it didn't work :(

Upvotes: 1

Views: 989

Answers (1)

Helge
Helge

Reputation: 11

In case you have not yet found the solution: Add the following to your .vimrc:

let g:vim_markdown_frontmatter = 1

It is documented here:

https://github.com/plasticboy/vim-markdown

Upvotes: 1

Related Questions