I'm using Kramdown-flavored Markdown in several of my Jekyll websites. Vim highlights all the underscores in those documents as errors, coloring them (in my color scheme) with bright red backgrounds. For those who don't know, Jekyll Markdown pages begin with a Yaml document containing metadata before the main document starts. Thus, at the top of an example file I have something like this:

layout: v4_main
date: Fall 1999
permalink: /music/effects_of_music.htm
# etc for many more lines

where all the underscores have bright red backgrounds. Throughout the actual Markdown portion of the document I have similar issues related to Kramdown's extensions to Markdown.

Following this advice, I managed to fix most of the issues by creating $HOME/.vim/after/syntax/markdown.vim with this line:

:syn match markdownIgnore "\v\w_\w"

However, the fix is incomplete, and I don't understand why. My documents have a number of headings that look like this:

## General Effects of Music {#general_effects_of_music}

The part in the curly braces is Kramdown's way of setting the header's id when rendering to HTML. Despite my updated Vim syntax rule, the underscores in the id are still labeled as errors. Any idea why, or how I can silence those errors?

NOTE: I've tested my regex in a search (/\v\w_\w) and it matched everything I want it to match, so clearly the issue isn't a bug in my regex.

  • 1
    Ive used the liquid plugin (i think from tpope) for my jekyll sites with no issue.
    – D. Ben Knoble
    Commented Jan 6, 2019 at 2:42
  • @user938271: It gets rid of the error coloring, but it also changes the color of underscores to be the same as the background color, making underscores appear as spaces. Commented Jan 6, 2019 at 2:57
  • Really? Ive not noticed that...
    – D. Ben Knoble
    Commented Jan 6, 2019 at 2:58
  • It's possible that it could be some interaction involving my color scheme (industry). Commented Jan 6, 2019 at 3:58

1 Answer 1


I didn't find a way to suppress the error markings in the kramdown ids. So why not highlight them differently? Perhaps like this:

syn match kramdownId "{#[^}]*}"
syn cluster markdownInline add=kramdownId
highlight def link kramdownId Identifier

This highlights {#...} in light blue (in my color scheme).

Note: I have no full kramdown file to test if there are any side effects.

  • This answer fixes my problem as I described it, though I've updated the match regex to handle all Kramdown identifiers: {[.:#][^}]*}. Nonetheless, in further testing I found yet more issues with the Markdown highlighter, so I've switched to using a plugin to highlight my Markdown. Commented Jan 6, 2019 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.