Vscode-markdown: Tools to create Tables

Created on 29 Jul 2017  ·  21Comments  ·  Source: yzhang-gh/vscode-markdown

  • Code snippet to create basic table layout.
    | | | | --- | --- | | | |
    Pressing Tab should loop the cursor in different cells
  • Right clicking inside the table should have options to Add New Row At End, Add New Column At End, Add New Row(Creates new Row next to the current row), Add New Column (Creates new Column next to the current Column), Delete Row(Deletes current Row), Delete Column(Deletes current Column).
Markdown table Help wanted Feature

Most helpful comment

Thanks for the information. This is similar to Caret I mentioned before

Caret is a good Markdown editor. It

  • creates tables on Enter based on header | abc | abc |
  • creates table rows on Enter
  • [added] goes to next cell on Tab
  • resizes table columns on typing/Tab

table-iloveimg-compressed

These are completely doable although also require much effort.

All 21 comments

Thanks for your suggestion.
It is a good feature. But I would like to think more about the UX. Right clicking to add row/column is kind of... "strange"

What about Shortcut keys? But I would prefer Right Click because it is more visible to users.
Will VS code API allows you to make a ToolBar?

vscode API provides very limited support for these customizations. That is why I am hesitant.

New Method. When the user places the cursor in a specific cell

  • Pressing Double Enter creates new Row
  • Pressing Double Tab creates new Column
  • Pressing Ctrl + Double Enter Deletes current Row
  • Pressing Ctrl + Double Tab Deletes current Column

I'm afraid that we cannot easily detect double enter/tab event… (how do we do when we find the enter key is pressed once? Breaking line immediately? Or waiting for another pressing?)

Thanks again for your suggestion.

And before I find a good way, you can add some simple shortcuts for workaround.

Then use

  • Ctrl + Enter(Tab) for Create
  • Shift + Enter(Tab) for Delete

Let me do some investigations on how other Markdown editors do this

Caret is a good Markdown editor. It

  • creates tables on Enter based on header | abc | abc |
  • creates table rows on Enter
  • resizes table columns on typing

table-iloveimg-compressed

Creating columns?

Caret cannot do that.

Typora has a custom control to change table size and alignment. But it is hard to bring that to vscode.

table-iloveimg-compressed 1

What about adding an additional column in header automatically creates a new column in the whole table?
Also, Alignment will be a good addition.

I agree that adding table body as typing table header is a natural way.
But some tricks are needed to implement this (because of vscode API). So at this time I'm not motivated to do it 😓.

As for the alignment, choose :---, ---: and :---: in the second line.

I think you can use CodeLens and CodeAction to provide these actions.

Put the cursor in a cell, then the CodeLens provides align left, align center, align right, insert column left, insert column right commands, while the CodeAction provides insert row above and insert row below commands.

Of course you can do that. But the problem is it will add too many "buttons" in the UI making it looks bad.

@neilsustc Is it possible to add Convert tabular data to tables feature? So that I can easily copy Excel data into a Markdown table.

Accessing clipboard is a big problem. More info here

The VSCode API doesn't provide methods to access the clipboard. There are several open issues regarding this issue (217, 4972, lots of duplicates), but it doesn't look like Microsoft has plans to implement an API for the clipboard. This could be an issue as there are several issues noted by users with the workaround libraries recommended by the VSCode team.

@neilsustc Maybe you can check this out: Markdown Shortcuts. It do have a Convert tabular data to tables feature in it.

OK, I understand now. (I thought you meaned to paste Markdown table directly from Excel data)

I opened another issue for it. You can use Markdown Shortcuts as a complement before that feature is added.

In case this feature is still being considered, Atom has an amazing package that is very intuitive to use: https://atom.io/packages/markdown-table-editor.

Shotcuts like tab to jump to a next cell are really useful.

Thanks for the information. This is similar to Caret I mentioned before

Caret is a good Markdown editor. It

  • creates tables on Enter based on header | abc | abc |
  • creates table rows on Enter
  • [added] goes to next cell on Tab
  • resizes table columns on typing/Tab

table-iloveimg-compressed

These are completely doable although also require much effort.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ichirou2910 picture ichirou2910  ·  3Comments

baby5 picture baby5  ·  5Comments

nosalan picture nosalan  ·  3Comments

jerry-sky picture jerry-sky  ·  4Comments

smallprogram picture smallprogram  ·  3Comments