Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 44477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:39:30+00:00 2026-05-10T15:39:30+00:00

I decide to learn more about vim and its syntax highlighting. Using examples for

  • 0

I decide to learn more about vim and its syntax highlighting. Using examples for others, I am creating my own syntax file for Markdown. I have seen mkd.vim and it has this problem too. My issue is between list items and code block highlighting.

Code Block definition:

  • first line is blank
  • second line begins with at least 4 spaces or 1 tab
  • block is finished with a blank line

Example:

Regular text      this is code, monospaced and left untouched by markdown     another line of code  Regular Text 

My Vim syntax for code block:

syn match mkdCodeBlock   /\(\s\{4,}\|\t\{1,}\).*\n/ contained nextgroup=mkdCodeBlock    hi link mkdCodeBlock  comment 

Unorder List item definition:

  • first line is blank
  • second line begins with a [-+*] followed by a space
  • the list is finished with a blank line then a normal (non-list) line
  • in between line items any number of blank lines can be added
  • a sub list is specified by indenting (4 space or 1 tab)
  • a line of normal text after a list item is include as a continuation of that list item

Example:

Regular text  - item 1      - sub item 1     - sub item 2 - item 2 this is part of item 2 so is this   - item 3, still in the same list     - sub item 1     - sub item 2  Regular text, list ends above 

My Vim syntax for unorder list item definition (I only highlight [-+*]):

syn region  mkdListItem start=/\s*[-*+]\s\+/ matchgroup=pdcListText end='.*' contained nextgroup=mkdListItem,mkdListSkipNL contains=@Spell skipnl  syn match mkdListSkipNL /\s*\n/ contained nextgroup=mkdListItem,mkdListSkipNL skipnl  hi link mkdListItem  operator 

I cannot get the highlighting to work with the last two rule for list and with a code block.

This is an example that breaks my syntax highlighting:

Regular text  - Item 1 - Item 2 part of item 2      - these 2 line should be highlighted as a list item     - but they are highlighted as a code block 

I currently cannot figure out how to get the highlighting to work the way I want it too


Forgot to add a ‘global’ syntax rule used in both rules listed below. It is to ensure a that they start with a blank line.

syn match mkdBlankLine   /^\s*\n/    nextgroup=mkdCodeBlock,mkdListItem transparent 

Another Note: I should have been more clear. In my syntax file, the List rules appear before the Blockquote Rules


  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T15:39:30+00:00Added an answer on May 10, 2026 at 3:39 pm

    Just make sure that the definition of mkdListItem is after the definition of mkdCodeBlock, like this:

    syn match mkdCodeBlock   /\(\s\{4,}\|\t\{1,}\).*\n/ contained nextgroup=mkdCodeBlock   hi link mkdCodeBlock  comment  syn region  mkdListItem start=/\s*[-*+]\s\+/ matchgroup=pdcListText end='.*' contained nextgroup=mkdListItem,mkdListSkipNL contains=@Spell skipnl  syn match mkdListSkipNL /\s*\n/ contained nextgroup=mkdListItem,mkdListSkipNL skipnl hi link mkdListItem  operator  syn match mkdBlankLine   /^\s*\n/    nextgroup=mkdCodeBlock,mkdListItem transparent 

    Vim documentation says in :help :syn-define:

    ‘In case more than one item matches at the same position, the one that was defined LAST wins. Thus you can override previously defined syntax items by using an item that matches the same text. But a keyword always goes before a match or region. And a keyword with matching case always goes before a keyword with ignoring case.’

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 94k
  • Answers 94k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could use .htc extensions on Html files. This puts… May 11, 2026 at 6:51 pm
  • Editorial Team
    Editorial Team added an answer I've got it figured out :) The trick is to… May 11, 2026 at 6:51 pm
  • Editorial Team
    Editorial Team added an answer Delayed answer, but yes -- I think what you are… May 11, 2026 at 6:51 pm

Related Questions

I work in a medium sized team and I run into these painfully large
I am fresh out of College (graduated in December with BS in Comp Sci).
As someone who has spent around 10 years programming web applications with Adobe's ColdFusion,
So I'm going to a job interview next week at a Java place, and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.