user276198
user276198

Reputation: 111

How do I change markdown heading color by heading level in VS Code editor?

My question is similar to this one but the answer given there is for Vim and I need one for VS Code. I'm a real newbie, and I tried to solve this myself, but these attempts failed me:

Help is very appreciated.

Upvotes: 11

Views: 11776

Answers (2)

iota
iota

Reputation: 56

I faced the same issue and find a way with the VSCode extension "Markdown header coloring"

Basically you have to

  • install the extension
  • set some custom settings in settings.json. You can find examples of custom settings in the section "User defined header coloring"
  • do not forget to reload the window after each modification: open Command Palette → type Reload window

Upvotes: 3

Nick P
Nick P

Reputation: 521

There is a built-in way to style text, including Markdown headings, in the editor without an extension, using VSCode's Colour Theme settings:

Open your settings.json (~/.config/Code/User/settings.json) or Ctrl+p "settings", and between the top-level {} insert for example:

"editor.tokenColorCustomizations": {
    "textMateRules": [
      {
          "scope": "heading.1.markdown entity.name.section.markdown, heading.1.markdown punctuation.definition.heading.markdown",
          "settings": {
              "foreground": "#9cecfb",
              "fontStyle": "bold",
          }
      },
      {
          "scope": "heading.2.markdown entity.name.section.markdown, heading.2.markdown punctuation.definition.heading.markdown",
          "settings": {
              "foreground": "#83a4d4",
          }
       }
    ]
}

Upvotes: 18

Related Questions