Search code examples
vimvim-syntax-highlighting

How to disable a syntax region in vim syntax highlighting?


I'm using Vim 8.0 and the default syntax/markdown.vim that comes with it, which is the 2016-08-20 version of Tim Pope's vim-markdown package.

This package has a bug that really annoys me on certain files: it considers any line indended by four or more spaces as a code block, including list continuations. Thus, in the following:

1. Agenda Item 1: Frob the Bazzit
   - The bazzit is something that makes us have
     very _short_ lines indeed.
   - Further frobbing is necessary

The line very _short_ lines indeed will be highlighted as a code block and the word short will not be italicised.

I'm happy with just completely disabling code block highlighting, at least in these circumstances, but I can't figure out how to do that after the fact. I've been testing with a ~/.vim/after/syntax/markdown.vim to tweak configuration, but I can't figure out how, once the

syn region markdownCodeBlock start="    \|\t" end="$" contained

has been executed in the system markdown.vim I can disable that in my after/syntax/markdown.vim. How do I do this?

(I have tried using highlight link markdownCodeBlock NONE, which does disable the code block colour on those lines, but unfortunately they are still marked as code block regions and still do not highlight any other markup in there, such as _italic_ or `code` inline markup.)


Solution

  • It looks like what you want to do is clear that particular syntax group:

    To clean up specific syntax groups for the current buffer:

    :syntax clear {group-name} ..
    

    This removes all patterns and keywords for {group-name}.

    But it looks like you can't clear specific definitions of a group. Just the entire group:

    :syn clear markdownCodeBlock