[GH-ISSUE #535] MD013: Automatically fix line length #437

Open
opened 2026-03-03 01:26:55 +03:00 by kerem · 3 comments
Owner

Originally created by @PhilipNelson5 on GitHub (Jul 13, 2022).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/535

When rule MD013/line-length is enabled and markdownlint is fixing rule violations, it would be helpful if it could reflow a multiline paragraph. This would greatly improve productivity when editing paragraphs broken at a specific column.

Originally created by @PhilipNelson5 on GitHub (Jul 13, 2022). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/535 When rule [MD013/line-length](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md013) is enabled and markdownlint is fixing rule violations, it would be helpful if it could reflow a multiline paragraph. This would greatly improve productivity when editing paragraphs broken at a specific column.
Author
Owner

@DavidAnson commented on GitHub (Jul 13, 2022):

This is a reasonable request, but it is not practical within the current constraints of the fix system. It’s also much more invasive than I think I’m comfortable with.

<!-- gh-comment-id:1183395837 --> @DavidAnson commented on GitHub (Jul 13, 2022): This is a reasonable request, but it is not practical within the current constraints of the fix system. It’s also much more invasive than I think I’m comfortable with.
Author
Owner

@PhilipNelson5 commented on GitHub (Jul 13, 2022):

That's fair, I have no idea what it would take to implement this. For anyone else looking for this feature, in vim gqip will format a paragraph and reflow it according to your configured textwidth. You still have to do it by hand on a paragraph by paragraph basis but it's far less tedious than reflowing the lines manually.

<!-- gh-comment-id:1183478624 --> @PhilipNelson5 commented on GitHub (Jul 13, 2022): That's fair, I have no idea what it would take to implement this. For anyone else looking for this feature, in vim `gqip` will format a paragraph and reflow it according to your configured `textwidth`. You still have to do it by hand on a paragraph by paragraph basis but it's far less tedious than reflowing the lines manually.
Author
Owner

@DavidAnson commented on GitHub (Jul 13, 2022):

Just to leave a note for anyone else who might look at this, there are two notable challenges that spring to mind:

Rule violations that offer a fix are only able to target a single line for edits. Reflow would typically involve multiple edits spanning multiple lines that need to be coordinated with each other. Improving the API is something I will do eventually, but it's not enough.

Applying multiple fixes at once works today by carefully ordering them so that they don't overlap or interfere with each other. That may not be possible with a paragraph reflow, so bulk fix operations may fail more often if reflow were attempted.

<!-- gh-comment-id:1183587238 --> @DavidAnson commented on GitHub (Jul 13, 2022): Just to leave a note for anyone else who might look at this, there are two notable challenges that spring to mind: Rule violations that offer a fix are only able to target a single line for edits. Reflow would typically involve multiple edits spanning multiple lines that need to be coordinated with each other. Improving the API is something I will do eventually, but it's not enough. Applying multiple fixes at once works today by carefully ordering them so that they don't overlap or interfere with each other. That may not be possible with a paragraph reflow, so bulk fix operations may fail more often if reflow were attempted.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#437
No description provided.