Skip to content

Spacing Rules

Compact YAML

Alias: compact-yaml

Removes leading and trailing blank lines in the YAML front matter.

Options

Name Description List Items Default Value
Inner New Lines Remove new lines that are not at the start or the end of the YAML N/A false

Examples

Remove blank lines at the start and end of the YAML Before:
---

date: today

title: unchanged without inner new lines turned on

---
After:
---
date: today

title: unchanged without inner new lines turned on
---
Remove blank lines anywhere in YAML with inner new lines set to true Before:
---

date: today


title: remove inner new lines

---

# Header 1


Body content here.
After:
---
date: today
title: remove inner new lines
---

# Header 1


Body content here.

Consecutive blank lines

Alias: consecutive-blank-lines

There should be at most one consecutive blank line.

Examples

Consecutive blank lines are removed Before:
Some text


Some more text
After:
Some text

Some more text

Convert Spaces to Tabs

Alias: convert-spaces-to-tabs

Converts leading spaces to tabs.

Options

Name Description List Items Default Value
Tabsize Number of spaces that will be converted to a tab N/A 4

Examples

Converting spaces to tabs with `tabsize = 3` Before:
- text with no indention
   - text indented with 3 spaces
- text with no indention
      - text indented with 6 spaces
After:
- text with no indention
    - text indented with 3 spaces
- text with no indention
        - text indented with 6 spaces
Converting spaces to tabs with `tabsize = 3` works in blockquotes Before:
> - text with no indention
>    - text indented with 3 spaces
> - text with no indention
>       - text indented with 6 spaces
After:
> - text with no indention
>   - text indented with 3 spaces
> - text with no indention
>       - text indented with 6 spaces

Empty Line Around Blockquotes

Alias: empty-line-around-blockquotes

Ensures that there is an empty line around blockquotes unless they start or end a document. Note: an empty line is either one less level of nesting for blockquotes or a newline character.

Examples

Blockquotes that start a document do not get an empty line before them. Before:
> Quote content here
> quote content continued
# Title here
After:
> Quote content here
> quote content continued

# Title here
Blockquotes that end a document do not get an empty line after them. Before:
# Heading 1
> Quote content here
> quote content continued
After:
# Heading 1

> Quote content here
> quote content continued
Blockquotes that are nested have the proper empty line added Before:
# Make sure that nested blockquotes are accounted for correctly
> Quote content here
> quote content continued
> > Nested Blockquote
> > content continued

**Note that the empty line is either one less blockquote indicator if followed/proceeded by more blockquote content or it is an empty line**

# Doubly nested code block

> > Quote content here
> > quote content continued
After:
# Make sure that nested blockquotes are accounted for correctly

> Quote content here
> quote content continued
>
> > Nested Blockquote
> > content continued

**Note that the empty line is either one less blockquote indicator if followed/proceeded by more blockquote content or it is an empty line**

# Doubly nested code block

> > Quote content here
> > quote content continued

Empty Line Around Code Fences

Alias: empty-line-around-code-fences

Ensures that there is an empty line around code fences unless they start or end a document.

Examples

Fenced code blocks that start a document do not get an empty line before them. Before:
``` js
var temp = 'text';
// this is a code block
```
Text after code block.
After:
``` js
var temp = 'text';
// this is a code block
```

Text after code block.
Fenced code blocks that end a document do not get an empty line after them. Before:
# Heading 1
```
Here is a code block
```
After:
# Heading 1

```
Here is a code block
```
Fenced code blocks that are in a blockquote have the proper empty line added Before:
# Make sure that code blocks in blockquotes are accounted for correctly
> ```js
> var text = 'this is some text';
> ```
>
> ```js
> var other text = 'this is more text';
> ```

**Note that the blanks blockquote lines added do not have whitespace after them**

# Doubly nested code block

> > ```js
> > var other text = 'this is more text';
> > ```
After:
# Make sure that code blocks in blockquotes are accounted for correctly

> ```js
> var text = 'this is some text';
> ```
>
> ```js
> var other text = 'this is more text';
> ```

**Note that the blanks blockquote lines added do not have whitespace after them**

# Doubly nested code block

> > ```js
> > var other text = 'this is more text';
> > ```
Nested fenced code blocks get empty lines added around them Before:
```markdown
# Header

````JavaScript
var text = 'some string';
````
```
After:
```markdown
# Header

````JavaScript
var text = 'some string';
````

```

Empty Line Around Horizontal Rules

Alias: empty-line-around-horizontal-rules

Ensures that there is an empty line around horizontal rules unless they start or end a document.

Examples

Horizontal rules that start a document do not get an empty line before them. Before:
***


Content
After:
***

Content
Horizontal rules that end a document do not get an empty line after them. Before:
***
Content
***
After:
***

Content

***
All types of horizontal rules are affected by this rule Before:
- Content 1
***
- Content 2
---
- Content 3
___
- Content 4
After:
- Content 1

***

- Content 2

---

- Content 3

___

- Content 4
YAML frontmatter is not affected by this rule Before:
---
prop: value
---

Content
After:
---
prop: value
---

Content
Paragraphs above `---` are treated as a heading and not spaced apart Before:
Content
---
After:
Content
---

Empty Line Around Math Blocks

Alias: empty-line-around-math-blocks

Ensures that there is an empty line around math blocks using Number of Dollar Signs to Indicate a Math Block to determine how many dollar signs indicates a math block for single-line math.

Examples

Math blocks that start a document do not get an empty line before them. Before:
$$
\boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
$$
some more text
After:
$$
\boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
$$

some more text
Math blocks that are singe-line are updated based on the value of `Number of Dollar Signs to Indicate a Math Block` (in this case its value is 2) Before:
$$\boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}$$
some more text
After:
$$\boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}$$

some more text
Math blocks that end a document do not get an empty line after them. Before:
Some text
$$
\boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
$$
After:
Some text

$$
\boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
$$
Math blocks that are not at the start or the end of the document will have an empty line added before and after them Before:
Some text
$$
\boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
$$
some more text
After:
Some text

$$
\boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
$$

some more text
Math blocks in callouts or blockquotes have the appropriately formatted blank lines added Before:
> Math block in blockquote
> $$
> \boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
> $$

More content here

> Math block doubly nested in blockquote
> > $$
> > \boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
> > $$
After:
> Math block in blockquote
>
> $$
> \boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
> $$

More content here

> Math block doubly nested in blockquote
>
> > $$
> > \boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
> > $$

Empty Line Around Tables

Alias: empty-line-around-tables

Ensures that there is an empty line around github flavored tables unless they start or end a document.

Examples

Tables that start a document do not get an empty line before them. Before:
| Column 1 | Column 2 |
|----------|----------|
| foo      | bar      |
| baz      | qux      |
| quux     | quuz     |
More text.
# Heading

**Note that text directly following a table is considered part of a table according to github markdown**
After:
| Column 1 | Column 2 |
|----------|----------|
| foo      | bar      |
| baz      | qux      |
| quux     | quuz     |

More text.
# Heading

**Note that text directly following a table is considered part of a table according to github markdown**
Tables that end a document do not get an empty line after them. Before:
# Heading 1
| Column 1 | Column 2 |
|----------|----------|
| foo      | bar      |
| baz      | qux      |
| quux     | quuz     |
After:
# Heading 1

| Column 1 | Column 2 |
|----------|----------|
| foo      | bar      |
| baz      | qux      |
| quux     | quuz     |
Tables that are not at the start or the end of the document will have an empty line added before and after them Before:
# Table 1
| Column 1 | Column 2 | Column 3 |
|----------|----------|----------|
| foo      | bar      | blob     |
| baz      | qux      | trust    |
| quux     | quuz     | glob     |
# Table 2 without Pipe at Start and End
| Column 1 | Column 2 |
:-: | -----------:
bar | baz
foo | bar
# Header for more content
New paragraph.
After:
# Table 1

| Column 1 | Column 2 | Column 3 |
|----------|----------|----------|
| foo      | bar      | blob     |
| baz      | qux      | trust    |
| quux     | quuz     | glob     |

# Table 2 without Pipe at Start and End

| Column 1 | Column 2 |
:-: | -----------:
bar | baz
foo | bar

# Header for more content
New paragraph.
Tables in callouts or blockquotes have the appropriately formatted blank lines added Before:
> Table in blockquote
> | Column 1 | Column 2 | Column 3 |
> |----------|----------|----------|
> | foo      | bar      | blob     |
> | baz      | qux      | trust    |
> | quux     | quuz     | glob     |

More content here

> Table doubly nested in blockquote
> > | Column 1 | Column 2 | Column 3 |
> > |----------|----------|----------|
> > | foo      | bar      | blob     |
> > | baz      | qux      | trust    |
> > | quux     | quuz     | glob     |
After:
> Table in blockquote
>
> | Column 1 | Column 2 | Column 3 |
> |----------|----------|----------|
> | foo      | bar      | blob     |
> | baz      | qux      | trust    |
> | quux     | quuz     | glob     |

More content here

> Table doubly nested in blockquote
>
> > | Column 1 | Column 2 | Column 3 |
> > |----------|----------|----------|
> > | foo      | bar      | blob     |
> > | baz      | qux      | trust    |
> > | quux     | quuz     | glob     |

Heading blank lines

Alias: heading-blank-lines

All headings have one blank line both before and after (except where the heading is at the beginning or end of the document).

Options

Name Description List Items Default Value
Bottom Ensures one blank line after headings N/A true
Empty Line Between YAML and Header Keep the empty line between the YAML frontmatter and header N/A true

Additional Info

Warning

If paragraph blank lines is on, a newline will still be added between a heading and a paragraph, even if Bottom is false. You can override this by adding a custom regex replacement rule with the following settings:

regex to find flags regex to replace
(^#+\s.*)\n+ gm $1\n

Examples

Headings should be surrounded by blank lines Before:
# H1
## H2


# H1
line
## H2
After:
# H1

## H2

# H1

line

## H2
With `Bottom=false` Before:
# H1
line
## H2
# H1
line
After:
# H1
line

## H2
# H1
line
Empty line before header and after YAML is removed with `Empty Line Between YAML and Header=false` Before:
---
key: value
---

# Header
Paragraph here...
After:
---
key: value
---
# Header

Paragraph here...

Line Break at Document End

Alias: line-break-at-document-end

Ensures that there is exactly one line break at the end of a document.

Examples

Appending a line break to the end of the document. Before:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
After:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Removing trailing line breaks to the end of the document, except one. Before:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
After:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Move Math Block Indicators to Their Own Line

Alias: move-math-block-indicators-to-their-own-line

Move all starting and ending math block indicators to their own lines using Number of Dollar Signs to Indicate a Math Block to determine how many dollar signs indicates a math block for single-line math.

Examples

Moving math block indicator to its own line when `Number of Dollar Signs to Indicate a Math Block` = 2 Before:
This is left alone:
$$
\boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
$$
The following is updated:
$$L = \frac{1}{2} \rho v^2 S C_L$$
After:
This is left alone:
$$
\boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
$$
The following is updated:
$$
L = \frac{1}{2} \rho v^2 S C_L
$$
Moving math block indicator to its own line when `Number of Dollar Signs to Indicate a Math Block` = 3 and opening indicator is on the same line as the start of the content Before:
$$$\boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
$$$
After:
$$$
\boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
$$$
Moving math block indicator to its own line when `Number of Dollar Signs to Indicate a Math Block` = 2 and ending indicator is on the same line as the ending line of the content Before:
$$
\boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}$$
After:
$$
\boldsymbol{a}=\begin{bmatrix}a_x \\ a_y\end{bmatrix}
$$

Paragraph blank lines

Alias: paragraph-blank-lines

All paragraphs should have exactly one blank line both before and after.

Additional Info

Warning

Do not use with two spaces between lines with consecutive content. They work differently and will result in unexpected results.

When Is a Blank Line Added?

When a paragraph has another line after the current one and it does not end in 2 or more spaces, <br>, <br/>, or \.

Examples

Paragraphs should be surrounded by blank lines Before:
# H1
Newlines are inserted.
A paragraph is a line that starts with a letter.
After:
# H1

Newlines are inserted.

A paragraph is a line that starts with a letter.
Paragraphs can be extended via the use of 2 or more spaces at the end of a line, a line break html or xml, or a backslash (\) Before:
# H1
Content  
Paragraph content continued <br>
Paragraph content continued once more <br/>
Paragraph content yet again\
Last line of paragraph
A new paragraph
# H2
After:
# H1

Content  
Paragraph content continued <br>
Paragraph content continued once more <br/>
Paragraph content yet again\
Last line of paragraph

A new paragraph

# H2

Remove Empty Lines Between List Markers and Checklists

Alias: remove-empty-lines-between-list-markers-and-checklists

There should not be any empty lines between list markers and checklists.

Examples

Blank lines are removed between ordered list items Before:
1. Item 1

2. Item 2
After:
1. Item 1
2. Item 2
Blank lines are removed between list items when the list indicator is '-' Before:
- Item 1

    - Subitem 1

- Item 2
After:
- Item 1
    - Subitem 1
- Item 2
Blank lines are removed between checklist items Before:
- [x] Item 1

    - [!] Subitem 1

- [ ] Item 2
After:
- [x] Item 1
    - [!] Subitem 1
- [ ] Item 2
Blank lines are removed between list items when the list indicator is '+' Before:
+ Item 1

    + Subitem 1

+ Item 2
After:
+ Item 1
    + Subitem 1
+ Item 2
Blank lines are removed between list items when the list indicator is '*' Before:
* Item 1

    * Subitem 1

* Item 2
After:
* Item 1
    * Subitem 1
* Item 2
Blanks lines are removed between like list types (ordered, specific list item indicators, and checklists) while blanks are left between different kinds of list item indicators Before:
1. Item 1

2. Item 2

- Item 1

    - Subitem 1

- Item 2

- [x] Item 1

    - [f] Subitem 1

- [ ] Item 2

+ Item 1

    + Subitem 1

+ Item 2

* Item 1

    * Subitem 1

* Item 2
After:
1. Item 1
2. Item 2

- Item 1
    - Subitem 1
- Item 2

- [x] Item 1
    - [f] Subitem 1
- [ ] Item 2

+ Item 1
    + Subitem 1
+ Item 2

* Item 1
    * Subitem 1
* Item 2

Alias: remove-link-spacing

Removes spacing around link text.

Examples

Space in regular markdown link text Before:
[ here is link text1 ](link_here)
[ here is link text2](link_here)
[here is link text3 ](link_here)
[here is link text4](link_here)
[   here is link text5  ](link_here)
[](link_here)
**Note that image markdown syntax does not get affected even if it is transclusion:**
![  here is link text6 ](link_here)
After:
[here is link text1](link_here)
[here is link text2](link_here)
[here is link text3](link_here)
[here is link text4](link_here)
[here is link text5](link_here)
[](link_here)
**Note that image markdown syntax does not get affected even if it is transclusion:**
![  here is link text6 ](link_here)
Space in wiki link text Before:
[[link_here| here is link text1 ]]
[[link_here|here is link text2 ]]
[[link_here| here is link text3]]
[[link_here|here is link text4]]
[[link_here|    here is link text5  ]]
![[link_here|   here is link text6  ]]
[[link_here]]
After:
[[link_here|here is link text1]]
[[link_here|here is link text2]]
[[link_here|here is link text3]]
[[link_here|here is link text4]]
[[link_here|here is link text5]]
![[link_here|here is link text6]]
[[link_here]]

Remove Space around Characters

Alias: remove-space-around-characters

Ensures that certain characters are not surrounded by whitespace (either single spaces or a tab). Note: this may causes issues with markdown format in some cases.

Options

Name Description List Items Default Value
Include Fullwidth Forms Include Fullwidth Forms Unicode block N/A true
Include CJK Symbols and Punctuation Include CJK Symbols and Punctuation Unicode block N/A true
Include Dashes Include en dash (–) and em dash (—) N/A true
Other symbols Other symbols to include N/A

Examples

Remove Spaces and Tabs around Fullwidth Characters Before:
Full list of affected characters: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz,.:;!?"'`^~ ̄_&@#%+-*=<>()[]{}⦅⦆|¦/\¬$£¢₩¥。、「」『』〔〕【】—…–《》〈〉
This is a fullwidth period   。 with text after it.
This is a fullwidth comma   ,  with text after it.
This is a fullwidth left parenthesis (  with text after it.
This is a fullwidth right parenthesis )  with text after it.
This is a fullwidth colon :  with text after it.
This is a fullwidth semicolon ;  with text after it.
  Removes space at start of line
After:
Full list of affected characters:0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz,.:;!?"'`^~ ̄_&@#%+-*=<>()[]{}⦅⦆|¦/\¬$£¢₩¥。、「」『』〔〕【】—…–《》〈〉
This is a fullwidth period。with text after it.
This is a fullwidth comma,with text after it.
This is a fullwidth left parenthesis(with text after it.
This is a fullwidth right parenthesis)with text after it.
This is a fullwidth colon:with text after it.
This is a fullwidth semicolon;with text after it.
Removes space at start of line
Fullwidth Characters in List Do not Affect List Markdown Syntax Before:
# List indicators should not have the space after them removed if they are followed by a fullwidth character

- [ contents here]
  -  [ more contents here] more text here
+   [ another item here]
* [ one last item here]

# Nested in a blockquote

> - [ contents here]
>   -  [ more contents here] more text here
> +  [ another item here]
> * [ one last item here]

# Doubly nested in a blockquote

> The following is doubly nested
> > - [ contents here]
> >   -   [ more contents here] more text here
> > +  [ another item here]
> > * [ one last item here]
After:
# List indicators should not have the space after them removed if they are followed by a fullwidth character

- [contents here]
  - [more contents here]more text here
+ [another item here]
* [one last item here]

# Nested in a blockquote

> - [contents here]
>   - [more contents here]more text here
> + [another item here]
> * [one last item here]

# Doubly nested in a blockquote

> The following is doubly nested
> > - [contents here]
> >   - [more contents here]more text here
> > + [another item here]
> > * [one last item here]

Remove Space Before or After Characters

Alias: remove-space-before-or-after-characters

Removes space before the specified characters and after the specified characters. Note: this may causes issues with markdown format in some cases.

Options

Name Description List Items Default Value
Remove Space Before Characters Removes space before the specified characters. Note: using { or } in the list of characters will unexpectedly affect files as it is used in the ignore syntax behind the scenes. N/A ,!?;:).’”]
Remove Space After Characters Removes space after the specified characters. >Note: using { or } in the list of characters will unexpectedly affect files as it is used in the ignore syntax behind the scenes. N/A ¿¡‘“([

Examples

Remove Spaces and Tabs Before and After Default Symbol Set Before:
In the end , the space gets removed  .
The space before the question mark was removed right ?
The space before the exclamation point gets removed !
A semicolon ; and colon : have spaces removed before them
‘ Text in single quotes ’
“ Text in double quotes ”
[ Text in square braces ]
( Text in parenthesis )
After:
In the end, the space gets removed.
The space before the question mark was removed right?
The space before the exclamation point gets removed!
A semicolon; and colon: have spaces removed before them
‘Text in single quotes’
“Text in double quotes”
[Text in square braces]
(Text in parenthesis)

Space after list markers

Alias: space-after-list-markers

There should be a single space after list markers and checkboxes.

Examples

A single space is left between the list marker and the text of the list item Before:
1.   Item 1
2.  Item 2

-   [ ] Item 1
- [x]    Item 2
    -  [ ] Item 3
After:
1. Item 1
2. Item 2

- [ ] Item 1
- [x] Item 2
    - [ ] Item 3

Space between Chinese Japanese or Korean and English or numbers

Alias: space-between-chinese-japanese-or-korean-and-english-or-numbers

Ensures that Chinese, Japanese, or Korean and English or numbers are separated by a single space. Follows these guidelines

Options

Name Description List Items Default Value
English Punctuations and Symbols Before CJK The list of non-letter punctuation and symbols to consider to be from English when found before Chinese, Japanese, or Korean characters. Note: "*" is always considered to be English and is necessary for handling some markdown syntaxes properly. N/A -+;:'"°%$)]
English Punctuations and Symbols After CJK The list of non-letter punctuation and symbols to consider to be from English when found after Chinese, Japanese, or Korean characters. Note: "*" is always considered to be English and is necessary for handling some markdown syntaxes properly. N/A -+'"([¥$

Examples

Space between Chinese and English Before:
中文字符串english中文字符串。
After:
中文字符串 english 中文字符串。
Space between Chinese and link Before:
中文字符串[english](http://example.com)中文字符串。
After:
中文字符串 [english](http://example.com) 中文字符串。
Space between Chinese and inline code block Before:
中文字符串`code`中文字符串。
After:
中文字符串 `code` 中文字符串。
No space between Chinese and English in tag Before:
#标签A #标签2标签
After:
#标签A #标签2标签
Make sure that spaces are not added between italics and chinese characters to preserve markdown syntax Before:
_这是一个数学公式_
*这是一个数学公式english*

# Handling bold and italics nested in each other is not supported at this time

**_这是一_个数学公式**
*这是一hello__个数学world公式__*
After:
_这是一个数学公式_
*这是一个数学公式 english*

# Handling bold and italics nested in each other is not supported at this time

**_ 这是一 _ 个数学公式**
*这是一 hello__ 个数学 world 公式 __*
Images and links are ignored Before:
[[这是一个数学公式english]]
![[这是一个数学公式english.jpg]]
[这是一个数学公式english](这是一个数学公式english.md)
![这是一个数学公式english](这是一个数学公式english.jpg)
After:
[[这是一个数学公式english]]
![[这是一个数学公式english.jpg]]
[这是一个数学公式english](这是一个数学公式english.md)
![这是一个数学公式english](这是一个数学公式english.jpg)
Space between CJK and English Before:
日本語englishひらがな
カタカナenglishカタカナ
ハンカクカタカナenglish123全角数字
한글english한글
After:
日本語 english ひらがな
カタカナ english カタカナ
ハンカクカタカナ english123全角数字
한글 english 한글

Trailing spaces

Alias: trailing-spaces

Removes extra spaces after every line.

Options

Name Description List Items Default Value
Two Space Linebreak Ignore two spaces followed by a line break ("Two Space Rule"). N/A false

Examples

Removes trailing spaces and tabs. Before:
# H1
Line with trailing spaces and tabs.         
After:
# H1
Line with trailing spaces and tabs.
With `Two Space Linebreak = true` Before:
# H1
Line with trailing spaces and tabs.  
After:
# H1
Line with trailing spaces and tabs.