Emacs: Edit Tables

By Xah Lee. Date: . Last updated: .

What is ASCII Table

This lets you to generate text drawing of tabular data.

Then you can edit it interactively, such as insert or delete column.

You can also convert it to HTML or LaTeX format.

Create a New Empty Table

To create a table, Alt+x table-insert

The result look like this:

emacs table-insert 2024-06-21
emacs table-insert 2024-06-21

Press Tab or Shift+Tab to go to neighbor cells.

Create a Table from Comma Separated Values (CSV)

table-capture
convert a text of tabular data into ASCII table.

Let's say you have this comma separated values:

,A,B,C
1,1a,1b,1c
2,2a,2b,2c
3,3a,3b,3c

Select the whole text, then Alt+x table-capture. It'll ask you these questions:

Emacs will then change it to this:

emacs table-capture 2024-06-21
emacs table-capture 2024-06-21

Using Table Menu

Once you have created a table, you can use the menu to do things. The menu [Table] will appear when your cursor is on a table cell.

emacs table menu 2024-06-21
emacs table menu 2024-06-21

Show All Table Commands

Alt+x apropos-command, then type ^table-

emacs table commands 2024-06-25
emacs table commands 2024-06-25

sample of useful ones:

Export Table to HTML

table-generate-source

convert ASCII table under cursor to HTML LaTeX or CALS format.

Reference

Emacs, table commands