MD009 - Remove trailing spaces¶
Aliases: no-trailing-spaces
What this rule does¶
Removes unnecessary spaces at the end of lines to keep your Markdown clean and consistent.
Why this matters¶
- Clean diffs: Trailing spaces create noisy changes in version control
- Parser compatibility: Some Markdown tools have issues with trailing whitespace
- Professional quality: Clean files without hidden characters look more polished
- File size: Removing unnecessary spaces reduces file size (slightly but it adds up!)
Examples¶
✅ Correct¶
❌ Incorrect¶
🔧 Fixed¶
Configuration¶
[MD009]
br-spaces = 2 # Number of spaces for hard line breaks (default: 2)
strict = false # Remove all trailing spaces, even line breaks (default: false)
list-item-empty-lines = false # Allow trailing spaces in empty list item lines (default: false)
Automatic fixes¶
This rule automatically removes trailing spaces from the end of lines. When strict is false, it preserves exactly 2 spaces (or your configured br_spaces) for intentional hard line breaks.
Learn more¶
- Line breaks in Markdown - When trailing spaces are actually useful
- CommonMark specification - Technical details about line breaks