Trim Whitespace trims unnecessary blank characters from your Obsidian documents. This is a common feature in code editing software, and mostly exists to pare down irksome document clutter.
The plugin operates on three different types of whitespace, with three different targets.
, stylised as ·)\t or , stylised as →)\r or \n, stylised as ¬)Trim whitespace at the end of each line, or open document.
| Before | After |
|---|---|
Hello·World!···· |
Hello·World! |
Hello·World!→→→ |
Hello·World! |
# Hello¬ |
# Hello¬ |
Trim whitespace at the start of each line, or open document.
| Before | After |
|---|---|
····Hello·World! |
Hello·World! |
→→→Hello·World! |
Hello·World! |
¬ |
# Hello¬ |
Trim groups of whitespace (2 or more consecutive inline spaces/tabs, or consecutive lines)
| Before | After |
|---|---|
Hello···World! |
Hello·World! |
Hello→→→World! |
Hello→World! |
# Hello¬ |
# Hello¬ |
Trim Whitespace also adds a ribbon button to trim document whitespace. Hold shift when clicking the button to trim whitespace in selection instead.
| Name | Description |
|---|---|
| Trim on Manual Save | Manually trim document with CTRL / CMD + S |
| Auto-Trim | Automatically trim document when modified, according to the settings below. |
| Auto-Trim Delay | Time to wait in seconds before auto-trimming. |
| Preserve Code Blocks | Whether to preserve whitespace within code blocks. |
| Trim Trailing Spaces | Trim spaces at the end of each line. |
| Trim Trailing Tabs | Trim tabs at the end of each line. |
| Trim Trailing Lines | Trim empty lines at the end of the document. |
| Preserve Indented Lists | Whether to preserve whitespace if used for list indentation. |
| Trim Leading Spaces | Trim spaces at the start of each line. |
| Trim Leading Tabs | Trim tabs at the start of each line. |
| Trim Leading Lines | Trim lines at the start of the document. |
| Trim Multiple Spaces | Trim groups of multiple inline spaces. |
| Trim Multiple Tabs | Trim groups of multiple inline tabs. |
| Trim Multiple Lines | Trim groups of multiple blank lines. |
To install, either:
Want to help develop or maintain this plugin? Please do! PRs and input extremely welcome!