Auto-format tables (add padding to cells) for easy plain-text reading

Use case or problem

Markdown tables can be difficult to read in plain text. See an example below from http://markdowntable.com

| Header 1 | Header 2 | Header 3 |
|----|---|-|
| data1a | Data is longer than header | 1 |
| d1b | add a cell|
|lorem|ipsum|3|
| | empty outside cells
| skip| | 5 |
| six | Morbi purus | 6 |

They are much easier to read in plain-text when they are formatted by adding padding to cells to align the pipe separators, like this:

| Header 1 | Header 2                   | Header 3 |
|----------|----------------------------|----------|
| data1a   | Data is longer than header | 1        |
| d1b      | add a cell                 |          |
| lorem    | ipsum                      | 3        |
|          | empty outside cells        |          |
| skip     |                            | 5        |
| six      | Morbi purus                | 6        |

This is useful when (1) working on a file from an Obsidian vault in another text editor that doesn’t render tables, or (2) copy-pasting Obsidian tables into another place where tables are not supported but pasting a well-formatted table into a code-block is a good work-around, e.g. in slack messages.

Proposed solution

The Advanced Tables plugin already does this by default. As soon as you exit a cell by pressing tab or enter, Advanced Tables auto-formats the table by adding appropriate amount of padding to each cell. It also has a command to format all tables in the current document.

It would be great if the same feature was implemented in the new native table editor.

Current workaround (optional)

There are workarounds but they are tedious.

  1. Copy-paste the table from Obsidian into some online markdown table formatting tool such as http://markdowntable.com and copy-paste the results from there to the destination.
  2. The new table editor doesn’t behave well if Advanced Tables plugin is active, so I have this plugin disabled now by default. The workaround is to temporarily enable the plugin, format the table, disable the plugin.

Related feature requests (optional)

I haven’t found a feature request related to this on the forum.

7 Likes

Now that advanced tables can no longer be used this becomes a lot more important.

The new table editor is great most of the time, but if you need to edit the source for any reason it’s a mess in there now.

1 Like

I think this would also be a reasonable feature request for the Linter community plugin.

2 Likes

I would rephrase that to “Markdown tables can be difficult to edit in plain text” without column alignment.

I wouldn’t.

1 Like

will be implemented in v1.5.4. No ETAs.

1 Like

Is it possible to disable this feature post v1.5.4?

Well, I have to say that I hate this feature. :sob:

In the obsidian repo which I am maintaining, there are many markdown documents containing long tables, and they are stored using git. It has been working very well before.

But now, as long as someone inserts some long content into any cell of a table, all rows of the entire table will be modified, which is a disaster for change tracking.

So, I hope, at least, there should be an option for users to turn off this feature. :rofl:

@Steech and @LexLee , I recommend checking if a feature request exists for what you want. If so you can upvote it (click the heart); if not you can post one.