0

I am unable to turn on syntax highlighting for Markdown. How do I do it?

Here's my version information:

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled May 15 2020 15:48:23)
Included patches: 1-758

Here's the relevant part of my vimrc

" Highlighting for markdown
autocmd BufNewFile,BufFilePre,BufRead *.md set filetype=markdown.pandoc
augroup filetype_markdown
  autocmd FileType markdown onoremap i= :<c-u>execute "normal! ?^==\\+$\r:nohlsearch\rkvg_"<cr>
  autocmd FileType markdown onoremap i- :<c-u>execute "normal! ?^--\\+$\r:nohlsearch\rkvg_"<cr>
augroup END

Originally, I had just the first block above in my vimrc based on this: https://stackoverflow.com/questions/10964681/enabling-markdown-highlighting-in-vim

It wasn't working, so I added the second block based on this: Vim not recognizing markdown and tex files

2
  • Do you have syntax enabled? Check for syntax in :scriptnames, or look for syntax enable/syntax on in your vimrc
    – D. Ben Knoble
    Nov 24, 2020 at 16:17
  • That worked @D.BenKnoble . Thanks!
    – wdb
    Nov 24, 2020 at 17:12

2 Answers 2

1

You need to turn on syntax highlighting explicitly:

syntax enable
0

Per comment to original post (@D.BenKnoble), I set :syntax enable, and the Markdown highlighting worked. Run :help :syntax for more details. (Scroll to the top of the help page and read down.) Apparently :syntax on has similar but not identical behavior.

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.