If the file is named *.markdown then the highlighting works correctly. If it is named *.md then it doesn't work.

Even if I type :set syntax=markdown, the highlighting doesn't turn on.

With other filetypes e.g. awk, I can turn on the highlighting by running :set syntax=awk. But this doesn't work for markdown.

Ultimately I want to make Vim recognize .md files as markdown, but when the autocommand didn't work I tried just setting the syntax directly and found that didn't work either.

What could be causing this?

I am using MobaXterm.

  • 2
    Does :set filetype=markdown help or is the filetype already set correctly?
    – cbaumhardt
    Feb 22, 2016 at 22:11
  • @cbaumhardt, sorry, I should have mentioned: I tried both set filetype=markdown and set syntax=markdown and neither made any difference.
    – Wildcard
    Feb 22, 2016 at 22:54
  • 2
    When I start my Vim 7.4 without my vimrc (vim -Nu NONE), write a small markdown example, enter :set filetype=markdown and :syntax on it works for me. Do you have syntax enabled? Are you using an old Vim version?
    – cbaumhardt
    Feb 22, 2016 at 23:23
  • 1
    @cbaumhardt, I'm using 7.3.646. I confirmed that doing what your comment suggested worked, and doing the same without the -Nu NONE did not work. My ~/.vimrc includes these lines for editing CFEngine files, then at the bottom I have set smartindent, filetype plugin indent on, syntax on which may be redundant but I was trying to get something else to work...any of these look like a likely culprit?
    – Wildcard
    Feb 23, 2016 at 2:03
  • Does :syntax on have no effect? At least you now know that it is related to your .vimrc. You can try to comment out blocks of code to figure out what causes this behaviour. The lines you linked don't look relevant to me.
    – cbaumhardt
    Feb 23, 2016 at 2:12

1 Answer 1


EDIT: As noted by @Christian Brabandt below, this is no longer the case. Can't imagine why I had to do this. :=(

You have to :set filetype=markdown or do it in an autocmd group.

Turns out that vim by default sets .md files to Modula-2 (except for README.md), so that overrides the syntax setting.

  • 1
    That is not correct. Vims default for .md files is markdown as can be seen here. This has been changed like 5 years ago. Mar 22, 2019 at 6: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.