I would like to adapt this syntax file so that the formatting in VIM matches more closely what this online Markdown editor (GitLab-flavor) displays (the output on the right is relevant, this is how I want the text to look in VIM). In particular, I am looking at the detection of italics triggered by framing text with asterisks.

I made some progress by simplifying the start and end patterns and by adding "oneline". But actually I would like the region to extend beyond a single line to an entire paragraph. In other words, the region should include subsequent lines until an empty line is encountered. If I omit the "oneline" attribute, the region just goes on and does not stop on an empty line. How can I make this region include subsequent non-empty lines but stop at the first empty line (or, obviously, the end pattern, whatever comes first)?

Note that a piece of text that contains the start pattern, but no end pattern and that is terminated by an empty line should NOT be detected as a region. The empty line is not an alternative end, it should just be interpreted as "stop looking here for the end pattern".

exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\*\S\@=" end="\S\@<=\*" keepend oneline contains=markdownLineStart' . s:concealends

An empty line can be recognized by two consecutive newlines. You can match everything that is not two newlines with the following pattern:


Place this between the "start" and "end" patterns to match the whole italicized region at once. It will require that your syntax item is a match rather than a region:

syn match markdownItalic "\*\S\@=\([^\n]\|\n[^\n]\)\{-}\S\@<=\*"

The \{-} ensures that the match ends at the first possible end-marker. Alternatively, you could include * in the negated character list.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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