Lint Markdown in VS Code
MarkdownLint provides immediate formatting diagnostics, repository-level rules, IntelliSense-backed configuration, and automatic fixes in Visual Studio Code.
Transcript 4 topics
Markdown linting basics
0:00Whether you're writing a read me, maybe some documentation or just submitting issues or PRs on GitHub, Markdown is really handy. And today's extension, we're gonna show you how to format it properly every time. Hello world, my name is Michael Jolley and I'm the bald bearded builder. Let's talk about Versus Code extensions. And matter of fact, if you enjoy talking about those or just hanging out with our developers, we stream on Twitch every Tuesday through Thursday at two Eastern seven GMT.
You can find us at twitch.tv ballgradedbuilder. And now let's talk about our extension. We mentioned earlier, there's a lot of uses for markdown and formatting it is just hard. And that's what this extension hopes to help. Markdown Lint provides styling basically like linting for our markdown so that we can be consistent through all of our documentation.
And it actually allows us to add configuration files to the repo so that other people working on documentation get those same rules applied. So it's a consistent experience through all of our documentation.
Install Markdown Lint
1:13So to install it, same as always, I've left a link in the description below. If you wanna read more about it, get a little bit of detail or the easiest way is to press that extension icon in Versus Code, search for markdown lint, it's all one word and press the install button. Once it's installed, let's open up a markdown file and you'll see all of the warnings from different formatting issues. I love that it underlines them and provides me context where what the error is and where it is. And actually, if you mouse over those little squiggly lines, you'll get a detail of what that error is and why it's an error.
One of the niceties about it is if you click on the little light bulb context menu, you can actually fix a lot of those errors in place. The extension will handle it for you. There are a lot of rules built into this extension already. It's pretty opinionated, but in a good way. And luckily you don't need to know them all.
The creators actually added a link onto their repo with a definition of all the rules, all the parameters about it. So you can read more about that. I'll actually leave a link to those rules in the description as well. But the main point to get across here is you don't need to know all those rules as you're typing and writing your markdown, the linter is working and will show you issues as they arise. There are three main ways to customize the extension.
Customize repo rules
2:33One is your user settings. Json file. Now, if you're like me, you don't like editing that file. It's no fun at all. You could also use the workspace settings file but that's the same deal.
I'm working with JSON. It's not really intuitive and I don't really know where it's at. The third option is my preferred way. You can create a .markdownlint RC or YAML or JSON file in the project's root And it will apply to all of the markdown in that folder and any sub folders as well. In that file, can enable or disable any rule or you can customize that rule.
And one thing I really like about this extension is it doesn't expect me to not only know all the rules, but it doesn't expect me to know all the settings in that config file. So when I start trying to customize one of those rules the way I want it, the IntelliSense is built in to let me know what options are available to me. And when I hit save, it's automatically gonna apply that change to any markdown files I've got open. The thing I really like about this is that style definition can stay with my repo in my project.
So if someone else opens this up and decides to help with the documentation or update the read me, that's fine. We're all gonna be following the same rules of indentation and casings and spaces, all those sorts of things just work naturally.
Fix on save
3:58One feature that's really nice and I highly recommend turning it on is the ability to fix any changes on save. So I mentioned earlier, you can click on that little context icon and fix it line by line. But by turning this setting on anytime you save the file it will automatically fix anything it can. And one thing about the fix, if you don't like it you can always control Z to undo it. Totally cool.
It doesn't get mad about that. So what do you use markdown for? I mentioned I use it for taking notes, for blog posts, for documentation. Are there any other use cases that you are using? I'd love to hear about it.
I love learning how to do new things. Listen, if you liked this video, then like this video. And if you wanna see more Visual Studio Code extension highlights, be sure to subscribe and ding that bell to know when we release a new video until next time.
Sign in to join in. Reading needs nothing.