Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have multicolored headings in markdown syntax in at least one of these editors: Sublime Text 3, Vim or Visual Studio Code?

Essentially I would like for my headings to look like this:

md

How could I accomplish this in markdown syntax? I prefer sublime text but would be happy if I can make this happen in Sublime Text 3, Vim or Visual Studio Code. Lastly, if getting the subheadings to produce multicolors is difficult, then, how could I change the hashtag color of all headings to the same color. For example, all of my headings would have green hashtags but the heading font color would be #FFFFFF.

Thank you for your help.

like image 778
hearsay Avatar asked Apr 07 '19 14:04

hearsay


1 Answers

In Vim, you can override your color scheme by adding the following in a new file named ~/.vim/after/syntax/markdown.vim:

syn match    customHeader1     "^# "
syn match    customHeader2     "^## "
syn match    customHeader3     "^### "
syn match    customHeader4     "^#### "
syn match    customHeader5     "^##### "

highlight customHeader1 ctermfg=34
highlight customHeader2 ctermfg=32
highlight customHeader3 ctermfg=127
highlight customHeader4 ctermfg=45
highlight customHeader5 ctermfg=220

It creates 5 syntax groups (customHeader1 to customHeader4) matching the given regexes. Then it defines the colors for those groups.

34, 32, 127, 45, 220 are the colors, They should match your example. It renders as follow:

Result

Also, you need to have:

syntax on

in your .vimrc

like image 81
padawin Avatar answered Nov 15 '22 08:11

padawin