Is it possible to have multicolored headings in ma

2019-08-10 05:37发布

问题:

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

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.

回答1:

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:

Also, you need to have:

syntax on

in your .vimrc