SquareTable
SquareTable is a VS Code extension for editing plain-text tables. It is a port of the Sublime Text package of the same name, itself a fork of SublimeTableEditor, extended for multiline Pandoc and reStructuredText grid tables.
Quick start
SquareTable is off until you enable it. Open the command palette and run either:
SquareTable: Enable for current view
SquareTable: Enable for current language
Then type:
|Name|Phone|
Press Ctrl+K, then Enter:
| Name | Phone |
|------|-------|
| | |
Use Tab and Shift+Tab to move between cells. SquareTable aligns the table as you move.
If automatic syntax detection is wrong, run SquareTable: Set table syntax for current view and pick one. This also enables SquareTable for that view.
Commands
Keys are the same on every platform. On macOS, Ctrl is Control and Alt is Option.
| Keys |
Action |
Ctrl+Shift+A |
Align the table. |
Tab / Shift+Tab |
Move to the next or previous cell. |
Enter |
Move down, creating a row when required. In a complete grid, insert a cell row. |
Alt+Left / Alt+Right |
Move the current column. |
Alt+Shift+Left |
Delete the current column. |
Alt+Shift+Right |
Insert a column to the left. |
Alt+Up / Alt+Down |
Move the current row. In a complete grid, move the logical row. |
Alt+Shift+Up |
Delete the current row. |
Alt+Shift+Down |
Insert a row above the current row. |
Ctrl+K, then - |
Insert a single separator below. |
Ctrl+K, then = |
Insert a header separator below. |
Ctrl+K, then Enter |
Insert a separator below and move to the following row. |
Alt+Enter |
Move the remainder of the current cell to the row below. |
Ctrl+J |
Join the current row with the next row. |
Ctrl+K, then \| |
Convert the selection from CSV. |
At the beginning or end of a line, Enter keeps its normal newline behaviour. Separator commands do not apply to Textile tables. Separator, split and join commands do not apply to complete bordered grids.
Every command is also available from the command palette under SquareTable:.
Supported table syntaxes
| Mode |
Intended syntax |
Simple |
Pipe tables using \| borders, with optional <, >, # alignment. |
EmacsOrgMode |
Org tables using \| and + separators. |
Pandoc |
Bordered Pandoc grid tables. |
MultiMarkdown |
MultiMarkdown and Pandoc pipe tables; colspan support is experimental. |
reStructuredText |
reStructuredText simple and grid tables. |
Textile |
Textile tables; rowspan and colspan support is experimental. |
Automatic detection uses the document language:
| Language |
SquareTable mode |
| Markdown |
MultiMarkdown |
| reStructuredText |
reStructuredText |
| Textile |
Textile |
| Anything else |
Simple |
Pandoc mode is not selected automatically. Use MultiMarkdown for Pandoc pipe tables and Pandoc for bordered grid tables.
Multiline grid tables
Multiline editing applies only to complete bordered tables in Pandoc or reStructuredText mode.
A logical row is everything between two complete horizontal borders. A cell row is one physical line within a cell:
+---------+-------------+
| Name | Tasks |
+=========+=============+
| Alice | - One |
| | - Two |
+---------+-------------+
| Bob | - One |
+---------+-------------+
Spans are read from the visible borders. Remove an internal | throughout a content band to join adjacent cells into a colspan; remove a horizontal segment and its + to continue a cell as a rowspan. Restore them to split the cell again. Literal pipes, Markdown escapes such as \|, and reStructuredText substitutions such as |name| stay content. Non-rectangular geometry is rejected without changing the table.
Cell-row commands
| Keys |
Action |
Enter |
Insert a cell row below the caret without splitting its text. |
Ctrl+Alt+Shift+Down |
Insert a cell row below the caret. |
Ctrl+Alt+Shift+Up |
Delete the current cell row. |
Ctrl+Alt+Up / Ctrl+Alt+Down |
Move the current row within its cell. |
Tab / Shift+Tab with a selection |
Indent or outdent selected list rows. |
Tab / Shift+Tab without a selection |
Move to the next or previous cell. |
Inserting after a list item (-, *, +, 1., 1) or a - [ ] task) continues the marker, and ordered lists are renumbered. Indentation follows the editor's tab size and spaces setting.
Complete-grid structural editing requires one caret and no selection. Column commands are refused when they would touch a rowspan or colspan.
Settings
Settings may be set globally, per workspace, or per language, for example under "[markdown]". The command palette can also toggle them for the current view only.
| Setting |
Default |
Effect |
squaretable.enableTableEditor |
false |
Enable SquareTable key bindings. |
squaretable.syntax |
auto |
Force one of the six modes listed above. |
squaretable.borderStyle |
default |
Use simple, emacs or grid borders in Simple mode. |
squaretable.customColumnAlignment |
true |
Recognise <, > and # alignment rows in Simple mode. |
squaretable.alignNumberRight |
true |
Right-align numeric columns. |
squaretable.detectHeader |
true |
Centre detected headers. |
squaretable.keepSpaceLeft |
false |
Preserve leading spaces in cell content. |
squaretable.intelligentFormatting |
true |
Remove redundant trailing cells when packing legacy span syntax. |
For example:
{
"[markdown]": {
"squaretable.enableTableEditor": true
},
"[restructuredtext]": {
"squaretable.enableTableEditor": true,
"squaretable.syntax": "reStructuredText"
}
}
CSV and CJK
Select delimited text, then press Ctrl+K, followed by |. SquareTable detects the CSV dialect and renders the selection using the active table syntax. If detection fails, each input line becomes a single cell.
Double-width CJK characters are accounted for when aligning columns. Use a monospaced font with suitable CJK glyphs.
Credits and licence
SquareTable is derived from SublimeTableEditor by Valery Kocubinsky and keeps the original Apache License 2.0.