vis-tables - Vis plugin for writing tables
ssh://anon@thyssentishman.com/vis-tables
Log | Files | Refs | Feed | Contribute | README | LICENSE

Commit: c5965426188be58c403799ce9af27423de3cf271
Parent: 7e6af9851a97e9b1ea570eafc4c34f2e2d85229c
Author: Johannes Thyssen Tishman
Date:   Mon, 28 Aug 2023 14:07:59 +0000

Add README

Diffstat:
A README | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

1 file changed, 123 insertions(+), 0 deletions(-)

diff --git a/README b/README
@@ -0,0 +1,123 @@
+vis-tables
+----------
+Vis plugin for writing tables
+
+
+Installation
+------------
+1. Clone this repo to your vis plugins directory.
+2. Add the following to you visrc.lua file:
+
+	require('plugins/vis-tables')
+
+
+Usage
+-----
+To start creating tables, first activate the table-mode as follows:
+
+	:set tablemode on
+
+In table-mode any line starting with the column separator (default:
+'|') as the first non-whitespace character is treated as part of a
+table. Pressing <Tab> when the cursor is on such a line will trigger
+a cursor jump to the next available cell. Analogously, pressing
+<S-Tab> will jump to the previous cell. When moving forward, if no
+further cells are available, a new row will be appended. Consider
+the following example where 'X' denotes the cursor position:
+
+	|Item|Price|QtyX
+
+Since the cursor is already on the last available cell, pressing
+<Tab> will create a new row:
+
+	| Item | Price | Qty |
+	| X    |       |     |
+
+As can be seen in the example, columns are automatically re-aligned
+and padded, so leading and trailing whitespaces or trailing column
+separators may be omitted.
+
+Rows may be separated explicitly by adding a horizontal rule. This
+can be done by appending the row separator (default: '-') immediately
+after the first column separator:
+
+	| Item    | Price [$] | Qty |
+	|-X
+	| Lemons  |         3 |   2 |
+	| Apples  |         2 |   4 |
+	| Chicken |        10 |   1 |
+
+Pressing <Tab> will create the horizontal rule and jump to the next
+available cell:
+
+	| Item    | Price [$] | Qty |
+	|---------+-----------+-----|
+	| Xemons  |         3 |   2 |
+	| Apples  |         2 |   4 |
+	| Chicken |        10 |   1 |
+
+As can be seen in the example, strings are automatically aligned
+to the left and numbers to the right.
+
+Lastly, columns may be added by simply typing outside of the table
+limits:
+
+	| Item    | Price [$] | Qty | TotalX
+	|---------+-----------+-----|
+	| Lemons  |         3 |   2 |
+	| Apples  |         2 |   4 |
+	| Chicken |        10 |   1 |
+
+Pressing <Tab> will automatically add the missing cells and jump
+to the next available cell:
+
+	| Item    | Price [$] | Qty | Total |
+	|---------+-----------+-----+-------|
+	| Xemons  |         3 |   2 |       |
+	| Apples  |         2 |   4 |       |
+	| Chicken |        10 |   1 |       |
+
+Note that if a column is to be prepended, a column separator must
+preceed the string for the row to be considered part of the table.
+
+
+Key Bindings
+------------
+
+| Keys  | Action                               |
+|-------+--------------------------------------|
+| <C-h> | Move the current column to the left  |
+| <C-r> | Move the current column to the right |
+| gh    | Move the current cell to the left    |
+| gj    | Move the current cell down           |
+| gk    | Move the current cell up             |
+| gl    | Move the current cell to the right   |
+
+
+Configuration
+-------------
+Table properties may be overriden from your visrc.lua file. To do
+so add the following to your visrc.lua and update the variables
+according to your needs:
+
+	plugin_vis_tables = require('plugins/vis-tables')
+
+	plugin_vis_tables.csep = '|'	-- Column separator
+	plugin_vis_tables.rsep = '-'	-- Row separator
+	plugin_vis_tables.xsep = '+'	-- Intersection separator
+	plugin_vis_tables.npad = 1	-- Column padding
+	plugin_vis_tables.ndec = 2	-- Float value precision
+
+Note that changing these also changes the characters that <Tab>
+reacts to. For example if the column and row separators are changed
+to '/' and '=' respectively, only lines starting with '/' as the
+first non-whitespace character will be treated as part of a table
+and horizontal rules will no longer be created with '|-' but with
+'/='.
+
+
+Notes
+-----
+This plugin tries to be as inobtrusive as possible and may even be
+left always active or configured as a per-filetype setting (e.g.
+for markdown).