Markdown highlighting is great (when it works), but I've seen a problem on two different boxes with underscores in inline code and I'm wondering if there's an easy solution.

When I put, for instance, file_names in inline code, the underscores in between the backticks are stripped of their special meaning as far as markdown rendering engines are concerned. However, Vim still highlights them differently. On one box (my Windows box using MobaXterm) the underscores themselves are highlighted in red, but none of the surrounding text is displayed differently (which isn't too bad). But on my Mac, all the text from one underscore to the next is highlighted with a white background (on my black background terminal) which is extremely distracting.

Is there a way to get the markdown syntax highlighting code to properly ignore the underscores when they occur between backticks?


1 Answer 1


I was annoyed by this also however I found out it is because underscores are a special character in markdown.

The solution is is to escape with backslash \_ or if it's code wrap in backticks. Also indenting with 4 spaces should work.


  • The point of my question was that underscores were being treated as special (by my Vim syntax highlighting) even when they were part of text wrapped in backticks.
    – Wildcard
    Commented Mar 5, 2021 at 19:28

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.