This module explores markdown linting and formatting in Visual Studio Code using extensions like Markdownlint and YAML Front Matter Lint.
This comprehensive guide explores advanced markdown linting and formatting techniques in VS Code. Learn how to configure global and project-specific settings using markdownlint.json files, understand rule inheritance, manage ignore patterns, and implement professional formatting workflows. Master the integration of Markdownlint and YAML Front Matter Lint extensions for consistent documentation quality across all your projects.
DavidAnson’s Markdownlint VS Code extension enables the use of a markdownlint.json file to define linting rules. To maintain consistency across all projects, this configuration file can be stored in the user’s home directory. Below are the contents of this global configuration file:
1{
2 "default": true,
3 "MD001": true,
4 "MD003": {
5 "style": "atx"
6 },
7 "MD004": {
8 "style": "dash"
9 },
10 "MD005": true,
11 "MD007": {
12 "indent": 2
13 },
14 "MD009": {
15 "br_spaces": 2
16 },
17 "MD010": true,
18 "MD011": true,
19 "MD012": {
20 "maximum": 1
21 },
22 "MD013": false,
23 "MD014": true,
24 "MD018": true,
25 "MD019": true,
26 "MD020": true,
27 "MD021": true,
28 "MD022": true,
29 "MD023": true,
30 "MD024": false,
31 "MD025": true,
32 "MD026": {
33 "punctuation": ":,;!?"
34 },
35 "MD027": true,
36 "MD028": true,
37 "MD029": {
38 "style": "ordered"
39 },
40 "MD030": true,
41 "MD031": true,
42 "MD032": true,
43 "MD033": false,
44 "MD034": true,
45 "MD035": true,
46 "MD036": true,
47 "MD037": true,
48 "MD038": true,
49 "MD039": true,
50 "MD040": true,
51 "MD041": false,
52 "MD042": true,
53 "MD043": false,
54 "MD044": true,
55 "MD045": true,
56 "MD046": {
57 "style": "fenced"
58 },
59 "MD047": true,
60 "MD048": {
61 "style": "backtick"
62 },
63 "MD049": {
64 "style": "underscore"
65 },
66 "MD050": true,
67 "MD051": true,
68 "MD052": true,
69 "MD053": true,
70 "MD059": false
71}
The above modified rules are a combination of default rules and some customizations. These customizations are based on personal preferences and specific project requirements. They are explained below:
# symbols) instead of Setext-style headers (using = or - underlines). This preference is often due to the cleaner look and easier readability of ATX headers in plain text.-) for unordered list markers instead of asterisks (*) or plus signs (+). Dashes are often preferred for their simplicity and visual clarity.:,;!?) are common in titles and headings, ensuring that headers remain clear and concise.The above rules are applied during the linting and formatting of Markdown files. To utilize this file globally, add its reference to the user’s settings.json file, making these settings available to every project. The settings.json file contains the following entries relevant to Markdown linting:
1// MARKDOWNLINT CONFIGURATION
2// =========================================================================
3"markdownlint.config": {
4 "extends": "/home/ag-sayyed/.markdownlint.json",
5 "defaultRules": {
6 // Add any rules you want to disable globally here
7 // "MD013": false,
8 }
9}
When global settings are configured, you have several options for project-specific implementation:
Your local project will automatically inherit the global settings. You can only add ignore patterns either in a markdownlint-cli2.jsonc file or in the project’s .vscode/settings.json file:
1// In markdownlint-cli2.jsonc file
2{
3 "ignores": [
4 "**/node_modules/**",
5 "**/dist/**",
6 "**/vendor/**",
7 "**/.git/**",
8 "**/.vscode/**",
9 "**/scripts/test-fixtures/*.md"
10 ]
11}
12
13// OR in .vscode/settings.json file
14{
15 "markdownlint.ignore": [
16 "scripts/test-fixtures/**",
17 "node_modules/**",
18 ".git/**"
19 ]
20}
Always prioritize configuration files in the project root. The
.vscode/settings.jsonfile serves as a fallback when no project-specific configuration file is present.
To override global settings, create project-specific rules or configurations in a local file. This approach allows customization of linting and formatting behavior for individual projects without affecting global settings. To implement this:
.markdownlint.jsonc file in your project root1{
2 "extends": "/home/ag-sayyed/.markdownlint.json",
3 "MD001": false // Disable heading level rule for this project
4}
Note
Both configuration settings and ignore patterns can be placed in only one file and have comments there to remind you what are these settings for. And it is done in a file named
.markdownlint-cli2.jsoncin this project instead of.markdownlint.jsonto demonstrate the use of comments injsoncfile
Content containing Markdown formatting issues will be displayed in the Problems tab of the VS Code panel and highlighted directly in the editor using colored squiggly lines.

Markdown content displaying linting issues from multiple extensions in VS Code
The red indicators are generated by the YAML Front Matter Lint extension, while the green indicators are produced by the Markdownlint extension. These issues are detected because the project is reading rules from the configuration file.
VS Code displays linting issues in the bottom panel’s Problems tab. The issues are explained in detail as shown below:

Comprehensive linting issues breakdown by installed extensions
To specify files and folders to ignore, create a new file named .markdownlint-cli2.jsonc in your project root directory. Add file patterns using the correct glob syntax **/<foldername>/**. For example, the following entry will successfully ignore all Markdown files from the specified folder /scripts/test-fixtures/*.md:
The extension uses
.markdownlint-cli2configuration format and follows its rules strictly. It does not support the.markdownlintignorefile. Instead, use theignoresentry in the.markdownlint-cli2.jsoncfile or other supported configuration files.
1// File: .markdownlint-cli2.jsonc
2{
3 "ignores": [
4 "**/node_modules/**",
5 "**/dist/**",
6 "**/build/**",
7 "**/scripts/test-fixtures/**"
8 ]
9}
Visual Indicators:
Create a sample Markdown file with unformatted content and test the formatting using all three available methods:
Ctrl+S to save the fileFormat DocumentAll methods should format the file according to the default settings defined in the global configuration.
Minimal Configuration: No local configuration files are required except for a single file following the markdownlint-cli2 format to ignore specific files using the ignores entry.
Automatic Formatting: Formatting is automatically triggered on focus change and save events as configured in global settings.
Extension-Based Processing: Only VS Code extensions are used for formatting; no project-specific formatters are installed.
Independent Extension Operation:
YAML Front Matter Lint extensionMarkdownlint extensionConfiguration Flexibility: Both extensions support their own configuration files when present in the project root.
Multiple Formatting Options: Formatting is available through context menu Format Document option as well as automatic triggers.
Prettier Integration: No Prettier configuration file is currently used.
Partial Issue Resolution: Not all linting or formatting issues are automatically fixed.
Clean Project Settings: No project-level settings exist in .vscode/settings.json or workspace files.
At this stage, the .vscode/settings.json file remains minimal, containing only intentional color customizations. No project-specific linting or formatting settings are present, ensuring that global/user settings are applied correctly.
1{
2 "workbench.colorCustomizations": {
3 "activityBar.background": "#0C0C9A",
4 "titleBar.activeBackground": "#1111D8",
5 "titleBar.activeForeground": "#FBFBFF"
6 }
7}
If your project is initialized as a Git repository, consider adding the following setting to your project’s
.vscode/settings.jsonfile to format the entire file on save:
1{
2 "editor.formatOnSaveMode": "file",
3 "workbench.colorCustomizations": {
4 "activityBar.background": "#0C0C9A",
5 "titleBar.activeBackground": "#1111D8",
6 "titleBar.activeForeground": "#FBFBFF"
7 }
8}
Markdownlint-cli2 cannot automatically fix heading levels or reformat your Markdown content. It’s a linter, not a formatter.
What markdownlint-cli2 does:
# instead of ##) using rules like MD001 (heading levels should increment by one).What it does not do:
For example, if you have a heading that should be ## instead of #, markdownlint-cli2 will flag it as an issue, but you’ll need to manually change it in your file. On the other hand if the same heading has another issue like missing space after #Heading, it will be automatically fixed as # Heading on save or focus change or on formatting either from context menu or running a CLI tool.
settings.json file:1{
2 "markdownlint.run": "onSave",
3 "editor.codeActionsOnSave": {
4 "source.fixAll.markdownlint": "explicit"
5 }
6}
This configuration ensures that linting only occurs when you save the file and all fixable issues are automatically resolved on explicit save actions. If you want to change this setting so all errors are fixed on every save, change "explicit" to "always".
This module demonstrates the effective implementation of Markdown linting and formatting in VS Code through a combination of global configurations and minimal project-specific settings. The approach ensures:
The configuration strikes an optimal balance between comprehensive linting coverage and ease of implementation, making it suitable for both individual developers and team environments.