Skip to content

Commit

Permalink
[docs] document macros and setcol-precision
Browse files Browse the repository at this point in the history
  • Loading branch information
anjakefala committed Nov 19, 2023
1 parent 8d30bea commit 9c31e8d
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/columns.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ The default for currency uses `locale.format_string()`. The default for int/floa
3. Move to the row referencing the column whose display you wish to format. Move the cursor to the fmtstr column.
4. Type `e` followed by *{:,.0f}* for an `int` type and *{:,.02f}* for a floating point type.

###### How to quickly adjust the precision of a float or date?

1. Ensure the column is either typed as a float (`%`), floatsi, currency (`$`), or date (`@`).
2. Press `SPACE` and type the longnames `setcol-precision-more` or `setcol-precision-less` to adjust the precision in the current column.

[Bind the longnames to keys](https://www.visidata.org/docs/customize/), if using these commands frequently.

###### How to set all date columns to be **month/day/year**.

The default can be set in a `~/.visidatarc`.
Expand Down
29 changes: 29 additions & 0 deletions docs/macros.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
eleventyNavigation:
key: Macros
order: 5
update: 2023-11-18
version: VisiData 3.0
---

# Macros

Macros allow you to bind a series of commands to a key and then replay those commands within a session by using that keystroke.

The basic usage is:
1. Press `m` (macro-record) to begin recording the macro.
2. Go through the commands you wish to record.
3. Then type `m` again to complete the recording, and prompt for the keystroke or longname to bind it to.

The macro will then be executed everytime the provided keystroke is used. Note: the Alt+keys and the function keys are left unbound; overridding other keys may conflict with existing bindings, now or in the future.

Executing a macro will the series of commands starting on the current row and column on the current sheet.

# The Macros Sheet

Use `gm` (`open-macros-or-whatever`) to open an index existing macros.

Macros can be marked for deletion (with `d`). Changes can then be committed with `z Ctrl+S`.

`Enter` will open the macro in the current row, and you can view the series of commands composing it.

44 changes: 44 additions & 0 deletions tests/golden/setcol_precision_less.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
OrderDate Region Rep Item Units Unit_Cost Total
2016-01-06 East Jones Pencil 95 2.0 189.05
2016-01-23 Central Kivell Binder 50 20.0 999.50
2016-02-09 Central Jardine Pencil 36 5.0 179.64
2016-02-26 Central Gill Pen 27 20.0 539.73
2016-03-15 West Sorvino Pencil 56 3.0 167.44
2016-04-01 East Jones Binder 60 5.0 299.40
2016-04-18 Central Andrews Pencil 75 2.0 149.25
2016-05-05 Central Jardine Pencil 90 5.0 449.10
2016-05-22 West Thompson Pencil 32 2.0 63.68
2016-06-08 East Jones Binder 60 9.0 539.40
2016-06-25 Central Morgan Pencil 90 5.0 449.10
2016-07-12 East Howard Binder 29 2.0 57.71
2016-07-29 East Parent Binder 81 20.0 1619.19
2016-08-15 East Jones Pencil 35 5.0 174.65
2016-09-01 Central Smith Desk 2 125.0 250.00
2016-09-18 East Jones Pen Set 16 16.0 255.84
2016-10-05 Central Morgan Binder 28 9.0 251.72
2016-10-22 East Jones Pen 64 9.0 575.36
2016-11-08 East Parent Pen 15 20.0 299.85
2016-11-25 Central Kivell Pen Set 96 5.0 479.04
2016-12-12 Central Smith Pencil 67 1.3 86.43
2016-12-29 East Parent Pen Set 74 16.0 1183.26
2017-01-15 Central Gill Binder 46 9.0 413.54
2017-02-01 Central Smith Binder 87 15.0 1305.00
2017-02-18 East Jones Binder 4 5.0 19.96
2017-03-07 West Sorvino Binder 7 20.0 139.93
2017-03-24 Central Jardine Pen Set 50 5.0 249.50
2017-04-10 Central Andrews Pencil 66 2.0 131.34
2017-04-27 East Howard Pen 96 5.0 479.04
2017-05-14 Central Gill Pencil 53 1.3 68.37
2017-05-31 Central Gill Binder 80 9.0 719.20
2017-06-17 Central Kivell Desk 5 125.0 625.00
2017-07-04 East Jones Pen Set 62 5.0 309.38
2017-07-21 Central Morgan Pen Set 55 12.5 686.95
2017-08-07 Central Kivell Pen Set 42 23.9 1005.90
2017-08-24 West Sorvino Desk 3 275.0 825.00
2017-09-10 Central Gill Pencil 7 1.3 9.03
2017-09-27 West Sorvino Pen 76 2.0 151.24
2017-10-14 West Thompson Binder 57 20.0 1139.43
2017-10-31 Central Andrews Pencil 14 1.3 18.06
2017-11-17 Central Jardine Binder 11 5.0 54.89
2017-12-04 Central Jardine Binder 94 20.0 1879.06
2017-12-21 Central Andrews Binder 28 5.0 139.72
44 changes: 44 additions & 0 deletions tests/golden/setcol_precision_more.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
OrderDate Region Rep Item Units Unit_Cost Total
2016-01-06 East Jones Pencil 95 1.99 189.050
2016-01-23 Central Kivell Binder 50 19.99 999.500
2016-02-09 Central Jardine Pencil 36 4.99 179.640
2016-02-26 Central Gill Pen 27 19.99 539.730
2016-03-15 West Sorvino Pencil 56 2.99 167.440
2016-04-01 East Jones Binder 60 4.99 299.400
2016-04-18 Central Andrews Pencil 75 1.99 149.250
2016-05-05 Central Jardine Pencil 90 4.99 449.100
2016-05-22 West Thompson Pencil 32 1.99 63.680
2016-06-08 East Jones Binder 60 8.99 539.400
2016-06-25 Central Morgan Pencil 90 4.99 449.100
2016-07-12 East Howard Binder 29 1.99 57.710
2016-07-29 East Parent Binder 81 19.99 1619.190
2016-08-15 East Jones Pencil 35 4.99 174.650
2016-09-01 Central Smith Desk 2 125.00 250.000
2016-09-18 East Jones Pen Set 16 15.99 255.840
2016-10-05 Central Morgan Binder 28 8.99 251.720
2016-10-22 East Jones Pen 64 8.99 575.360
2016-11-08 East Parent Pen 15 19.99 299.850
2016-11-25 Central Kivell Pen Set 96 4.99 479.040
2016-12-12 Central Smith Pencil 67 1.29 86.430
2016-12-29 East Parent Pen Set 74 15.99 1183.260
2017-01-15 Central Gill Binder 46 8.99 413.540
2017-02-01 Central Smith Binder 87 15.00 1305.000
2017-02-18 East Jones Binder 4 4.99 19.960
2017-03-07 West Sorvino Binder 7 19.99 139.930
2017-03-24 Central Jardine Pen Set 50 4.99 249.500
2017-04-10 Central Andrews Pencil 66 1.99 131.340
2017-04-27 East Howard Pen 96 4.99 479.040
2017-05-14 Central Gill Pencil 53 1.29 68.370
2017-05-31 Central Gill Binder 80 8.99 719.200
2017-06-17 Central Kivell Desk 5 125.00 625.000
2017-07-04 East Jones Pen Set 62 4.99 309.380
2017-07-21 Central Morgan Pen Set 55 12.49 686.950
2017-08-07 Central Kivell Pen Set 42 23.95 1005.900
2017-08-24 West Sorvino Desk 3 275.00 825.000
2017-09-10 Central Gill Pencil 7 1.29 9.030
2017-09-27 West Sorvino Pen 76 1.99 151.240
2017-10-14 West Thompson Binder 57 19.99 1139.430
2017-10-31 Central Andrews Pencil 14 1.29 18.060
2017-11-17 Central Jardine Binder 11 4.99 54.890
2017-12-04 Central Jardine Binder 94 19.99 1879.060
2017-12-21 Central Andrews Binder 28 4.99 139.720
4 changes: 4 additions & 0 deletions tests/setcol_precision_less.vdj
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!vd -p
{"sheet": null, "col": null, "row": null, "longname": "open-file", "input": "sample_data/sample.tsv", "keystrokes": "o", "comment": null}
{"sheet": "sample", "col": "Unit_Cost", "row": "", "longname": "type-float", "input": "", "keystrokes": "%", "comment": "set type of current column to float"}
{"sheet": "sample", "col": "Unit_Cost", "row": "", "longname": "setcol-precision-less", "input": "", "comment": "show less precision in current column"}
4 changes: 4 additions & 0 deletions tests/setcol_precision_more.vdj
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!vd -p
{"sheet": null, "col": null, "row": null, "longname": "open-file", "input": "sample_data/sample.tsv", "keystrokes": "o", "comment": null}
{"sheet": "sample", "col": "Total", "row": "", "longname": "type-currency", "input": "", "keystrokes": "$", "comment": "set type of current column to currency"}
{"sheet": "sample", "col": "Total", "row": "", "longname": "setcol-precision-more", "input": "", "comment": "show more precision in current column"}

0 comments on commit 9c31e8d

Please sign in to comment.