3 Tables

Org comes with a fast and intuitive table editor. Spreadsheet-like calculations are supported in connection with the Emacs Calc package (see GNU Emacs Calculator Manual).

Org makes it easy to format tables in plain ASCII. Any line with ‘|’ as the first non-whitespace character is considered part of a table. ‘|’ is also the column separator. A table might look like this:

| Name  | Phone | Age |
|-------+-------+-----|
| Peter |  1234 |  17 |
| Anna  |  4321 |  25 |

A table is re-aligned automatically each time you press TAB or RET or C-c C-c inside the table. TAB also moves to the next field (RET to the next row) and creates new table rows at the end of the table or before horizontal lines. The indentation of the table is set by the first line. Any line starting with ‘|-’ is considered as a horizontal separator line and will be expanded on the next re-align to span the whole table width. So, to create the above table, you would only type

|Name|Phone|Age|
|-

and then press TAB to align the table and start filling in fields. Even faster would be to type ‘|Name|Phone|Age’ followed by C-c RET.

When typing text into a field, Org treats DEL, Backspace, and all character keys in a special way, so that inserting and deleting avoids shifting other fields. Also, when typing immediately after point was moved into a new field with TAB, S-TAB or RET, the field is automatically made blank.

Creation and conversion

C-c |

Convert the active region to table. If every line contains at least one TAB character, the function assumes that the material is tab separated. If every line contains a comma, comma-separated values (CSV) are assumed. If not, lines are split at whitespace into fields.

If there is no active region, this command creates an empty Org table. But it is easier just to start typing, like | N a m e | P h o n e | A g e RET | - TAB.

Re-aligning and field motion

C-c C-c

Re-align the table without moving point.

TAB

Re-align the table, move to the next field. Creates a new row if necessary.

S-TAB

Re-align, move to previous field.

RET

Re-align the table and move down to next row. Creates a new row if necessary.

S-UP
S-DOWN
S-LEFT
S-RIGHT

Move a cell up, down, left, and right by swapping with adjacent cell.

Column and row editing

M-LEFT, M-RIGHT

Move the current column left/right.

M-S-LEFT

Kill the current column.

M-S-RIGHT

Insert a new column to the left of point position.

M-UP, M-DOWN

Move the current row up/down.

M-S-UP

Kill the current row or horizontal line.

M-S-DOWN

Insert a new row above the current row. With a prefix argument, the line is created below the current one.

C-c -

Insert a horizontal line below current row. With a prefix argument, the line is created above the current line.

C-c RET

Insert a horizontal line below current row, and move the point into the row below that line.

C-c ^

Sort the table lines in the region. The position of point indicates the column to be used for sorting, and the range of lines is the range between the nearest horizontal separator lines, or the entire table.