Markdown with VS Code
Preface
As I will be writing lots of Markdowns, I spend some time researching VS Code Markdown extensions and creating snippets to enhance the writing experience.
Extensions
markdownlint
markdownlint applies a set of linting rules to Markdown file.
To exclude certain rules, you can add following configuration to VS Code settings at .vscode/settings.json
(This settings file only applies to Workspace level, which I recommend it over User level).
Below is an example to exclude inline-html from linting:
1 | "markdownlint.config": { |
Coloring Header
Markdown Header Coloring colors Markdown header tags.
I use a dark theme called Shades of Purple for VS Code. In this theme, the heading syntax is not very prominent, as the author says he prefers the syntax to be as hidden as possible. I like this theme a lot, but my only complaint is this hidden heading syntax, hence I find this extension extremely helpful!
GitHub Style Preview
Markdown Preview GitHub Styling changes the built-in markdown to match GitHub’s styling.
Snippets
Code snippets are templates that make it easier to enter repeating code patterns, such as loops or conditional-statements.
From Snippets in VS Code. (You can try for
in a JavaScript file with VS Code to learn how to use a snippet.)
Enable Quick Suggestion
Before using snippets in a Markdown file, quick suggestions in VS Code needs to be enabled. From the Intellisense page, it is enabled only for certain languages (Like JavaScript, TypeScript, JSON and etc.). Support for other languages (e.g. Python, Go and etc.) are managed by their corresponding extentions.
For Markdown, we can enable quick suggestions in VS Code settings (Code -> Preferences -> Settings):
- Once in the settings page, you can decide whether to apply this setting to User or Workspace level by toggle between User and Workspace. (I prefer to keep language specific settings at Workspace level though.)
- Go to the top right corner and look for “Open Settings (JSON)” button and click it.
- Type
"[markdown]"
and select[markdown]
from the quick suggestion popup window (Because the settings file is JSON, so quick suggestion works there 😜).
Markdown Snippets
Then change the [markdown]
settings to:
1 | "[markdown]": { |
After that we can start adding customized snippets for Markdown in VS Code. Go to User Snippets (Code -> Preferences -> User Snippets) and select markdown.json
. Below are snippets I used:
1 | { |
Referrence
Some Markdown snippets are from vscode-snippets-markdown (The use of
$CLIPBOARD
is really clever!)“Step 6: Create Choices” for custom snippet (I never know snippet placeholder could have choices!)