2

In a Vim markdown file (:set filetype=markdown), special items such as links and itacized text are normally syntax highlighted, but when they appear in a list more than three levels deep, they appear as regular, not highlighted text.

Is this a bug or intended behavior? Is there a way to get around it?

Example:

- [Level one list items are highlighted normally](https://www.vim.org)
    - [Level two list items are *still* highlighted](https://www.vim.org)
        - [List items three or more levels deep are *no longer highlighted*](https://www.vim.org)
3

Your example lines make up a nested list. Looking in $VIMRUNTIME/syntax/markdown.vim at the syn line with the pattern that matches list lines...

" TODO: real nesting
syn match markdownListMarker "\%(\t\| \{0,4\}\)[-*+]\%(\s\+\S\)\@=" contained

Translation: currently you can only have one tab or 0-4 spaces preceding the list marker char (-, *, or +). The TODO appears to indicate that this is a known limitation.

What does this have to do with syntax highlighting of links and italicized text? Well, the lines that don't get designated as list items are instead being tagged as code blocks (MarkdownCodeBlock) and within code blocks there's no syntax highlighting for those things.

There may be a bug opened for this already but you might want to check. If it does exist you could try to get it some attention.

Other than that you could try to fix the syntax yourself or, if that's not something you're up for, you could look for third party Markdown syntax files...there's a decent chance there's an improved version somewhere out in the interwebs.

Update: For a quick-and-dirty workaround...at least for your particular example...you could change that 4 in \{0,4\} to a larger number so deeper indents still get recognized as list lines. It'll work though it could have negative side effects, i.e. break some other part of the Markdown file synhi...you'll have to test it to find out for sure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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