Juha-Matti Santala
Community Builder. Dreamer. Adventurer.

🍿 ,table to generate Markdown tables

Snacks (🍿) are my collection of recipes for solving problems. Often recorded (and cleaned up) from actual discussions where I'm involved in helping others with technical problems. Not all solutions are mine but I started collecting them in one place because you never know when you need one.


I use Markdown all the time and love it. But Markdown tables are cumbersome to set up.

The syntax for a Markdown table looks like this:

| Column header 1 | Column header 2 | Column header 3 |
| --------------- | --------------- | --------------- |
| Row 1, col 1    | Row 1, col 2    | Row 1, col 3    |
| Row 2, col 1    | Row 2, col 2    | Row 2, col 3    |

To make this easier, I created ,table that takes one argument column-count and creates a table template for that many columns.

$ ,table 3
|_|_|_|
|-|-|-|
|_|_|_|

It uses _ as the placeholder value for cells and prints the first row.

With

$ ,table 3 | pbcopy

I can copy it directly to clipboard (on macos) to make life even easier.