26

The Markdownlint plugin in Visual Studio Code is raising an MD007 error.

I'd like to update the setting but can't work out how to find the options.config referred to in the markdownlint documentation?

3 Answers 3

36
+250

The trick is explained in the vscode-markdownlint repo (diff from the primary markdownlint repo):

Rules can also be configured using Code's support for user and workspace settings.

  1. In Visual Studio Code, open File -> Preferences -> Settings or use CTRL + ,

  2. Edit the User Settings tab on the right to something like this:

    "markdownlint.config": {
        "default": true,
        "MD007": { "indent": 4 }
    }
    
0
13

I'd like to provide an update on this as of VS Code v1.28.2., markdownlint v0.21.0.

Per the official documentation, to provide a custom configuration, you simply put a .markdownlint.json at the root directory of your project.

For example, consider the following folder structure:

.
│   .markdownlint.json
├───docs
│       sitesetup.md
└───src

and now consider the following content in .markdownlint.json:

{
    "default": true,
    "MD007": false
}

VS Code would now load that custom markdownlint configuration when editing any markdown files within that folder hierarchy.

You can find the official documentation here.

3
  • 2
    You can also use YAML format instead of JSON here - the config file name must then be either .markdownlint.yaml or .markdownlint.yml. The avantage is you'll be able to add comments on why some rule was disabled (YAML supports comments whereas JSON does not) Nov 21, 2019 at 9:37
  • If you prefer JSON but still want comments, you can use .markdownlint.jsonc (JSON with Comments. Sep 17, 2021 at 10:45
  • Forgot to add: the big advantage of using .json or .jsonc in VS Code is full IntelliSense - very handy for working with configs like this. Sep 17, 2021 at 10:53
3

With markdownlint 0.29, I wasn't able to get this working by using the rule name. On the documentation, there's an alias that I had to use instead, ul-indent. My settings.json file ended up looking like:

{
    "git.autofetch": true,
    "markdownlint.config": {
        "default": true,
        "no-inline-html": { "allowed_elements": ["pre"] },
        "ul-indent": { "indent": 4 }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.