[GH-ISSUE #400] Feature request: MD012 (Multiple consecutive blank lines) option to ignore them at the end of file #2180

Closed
opened 2026-03-07 20:05:19 +03:00 by kerem · 6 comments
Owner

Originally created by @orionlee on GitHub (May 24, 2021).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/400

For MD012 (Multiple consecutive blank lines), it'd be great if there is an option to ignore consecutive blank line at the end of a file.

Rationale: for a live file (i.e., actively edited),

  • typically I add content at the end of the file.
  • I want to center the edit line in the center (or above center) of the screen.
  • In order to do so in the editors I know (e.g. vscode), I need to add some (blank) lines at the end of the file.
  • Such end-of-file blank lines generate warnings in the editors, which I'd like to suppress.

Note: to complete the use case, such option needs to be exposed in the correspond editor extension as well, vscode-markdownlint in my use case.

Originally created by @orionlee on GitHub (May 24, 2021). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/400 For [MD012](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md012) (Multiple consecutive blank lines), it'd be great if there is an option to ignore consecutive blank line at the end of a file. Rationale: for a live file (i.e., actively edited), - typically I add content at the end of the file. - I want to center the edit line in the center (or above center) of the screen. - In order to do so in the editors I know (e.g. vscode), I need to add some (blank) lines at the end of the file. - Such end-of-file blank lines generate warnings in the editors, which I'd like to suppress. Note: to complete the use case, such option needs to be exposed in the correspond editor extension as well, vscode-markdownlint in my use case.
kerem 2026-03-07 20:05:19 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@waldyrious commented on GitHub (May 24, 2021):

In order to do so in the editors I know (e.g. vscode), I need to add some (blank) lines at the end of the file.

You might be interested in https://github.com/microsoft/vscode/issues/56174 :)

<!-- gh-comment-id:846977881 --> @waldyrious commented on GitHub (May 24, 2021): > In order to do so in the editors I know (e.g. vscode), I need to add some (blank) lines at the end of the file. You might be interested in https://github.com/microsoft/vscode/issues/56174 :)
Author
Owner

@DavidAnson commented on GitHub (May 24, 2021):

Thanks, @waldyrious, it sounds like this is best implemented in the editor - and very nearly supported today.

@orionlee, it seems your only interest here is at edit time, so I'm inclined not to change the linter.

<!-- gh-comment-id:847123311 --> @DavidAnson commented on GitHub (May 24, 2021): Thanks, @waldyrious, it sounds like this is best implemented in the editor - and very nearly supported today. @orionlee, it seems your only interest here is at edit time, so I'm inclined not to change the linter.
Author
Owner

@orionlee commented on GitHub (May 24, 2021):

At least for vscode, I don't think it is supported - The issue listed was first submitted in 2018 with no obvious resolution.

The closest vscdoe setting I know of is editor.cursorSurroundingLines, but it doesn't quite do what I want either. I end up adding extra blank lines at the end of the file to compensate editor.cursorSurroundingLines.

In my current use case, the extra blank lines at the end of file do get saved: I don't want to add blank lines to the file every time I open and edit it.

Now that I think about it more, I guess I have another workaround, by adding non-blank lines to the end of the file. It's uglier but is sufficient for my use case.

@DavidAnson Certainly it can be argued that it should be supported in the editor. Whether markdownlint (or vscode-markdownlint) does anything to support the use case is largely a judgement call. Thanks for the plugin and listening anyway!

<!-- gh-comment-id:847157054 --> @orionlee commented on GitHub (May 24, 2021): At least for vscode, I don't think it is supported - The issue listed was first submitted in 2018 with no obvious resolution. The closest vscdoe setting I know of is `editor.cursorSurroundingLines`, but it doesn't quite do what I want either. I end up adding extra blank lines at the end of the file to compensate `editor.cursorSurroundingLines`. In my current use case, the extra blank lines at the end of file do get saved: I don't want to add blank lines to the file every time I open and edit it. Now that I think about it more, I guess I have another workaround, by adding non-blank lines to the end of the file. It's uglier but is sufficient for my use case. @DavidAnson Certainly it can be argued that it should be supported in the editor. Whether `markdownlint` (or `vscode-markdownlint`) does anything to support the use case is largely a judgement call. Thanks for the plugin and listening anyway!
Author
Owner

@DavidAnson commented on GitHub (May 25, 2021):

Are you aware of this:

  // When enabled, will trim all new lines after the final new line at the end of the file when saving it.
  "files.trimFinalNewlines": false,
<!-- gh-comment-id:847532814 --> @DavidAnson commented on GitHub (May 25, 2021): Are you aware of this: ``` // When enabled, will trim all new lines after the final new line at the end of the file when saving it. "files.trimFinalNewlines": false, ```
Author
Owner

@orionlee commented on GitHub (May 25, 2021):

I'm a bit unclear on how files.trimFinalNewlines would help in the use case.
E.g., if I set files.trimFinalNewlines to true,

  1. I edit a file, and pad some blank lines at the end of file. (to keep edit line above the center of the screen)
  2. There would be some lint error about the blank lines. I ignore it.
  3. I save the file. The blank lines are trimmed.
  4. I open the file again, and I'd need to pad it with some blank lines again.

Right now, I have files.trimFinalNewlines set to false, so that I don't need to re-pad the file when I open to edit it again.

<!-- gh-comment-id:848087066 --> @orionlee commented on GitHub (May 25, 2021): I'm a bit unclear on how `files.trimFinalNewlines` would help in the use case. E.g., if I set `files.trimFinalNewlines` to `true`, 1. I edit a file, and pad some blank lines at the end of file. (to keep edit line above the center of the screen) 2. There would be some lint error about the blank lines. I ignore it. 3. I save the file. The blank lines are trimmed. 4. I open the file again, and I'd need to pad it with some blank lines again. Right now, I have `files.trimFinalNewlines` set to `false`, so that I don't need to re-pad the file when I open to edit it again.
Author
Owner

@DavidAnson commented on GitHub (Jun 19, 2021):

Closing this because it seems like more of an editor feature - and something you only want when editing.

<!-- gh-comment-id:864353708 --> @DavidAnson commented on GitHub (Jun 19, 2021): Closing this because it seems like more of an editor feature - and something you only want when editing.
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#2180
No description provided.