2020-07-30 05:29:03 +02:00
|
|
|
# Table autoformating
|
2020-08-12 17:17:00 +02:00
|
|
|
# Very configurable: read doc/design_notes.md
|
2019-12-15 05:37:28 +01:00
|
|
|
|
2020-07-21 21:10:27 +02:00
|
|
|
# Do not alter config {{{1
|
|
|
|
##########################
|
2019-12-15 05:37:28 +01:00
|
|
|
|
2020-07-21 21:10:27 +02:00
|
|
|
Given vimwiki (Table Head \#891):
|
|
|
|
| foo | bar |
|
|
|
|
|
|
|
|
Execute (set tw=71):
|
|
|
|
set tw=71
|
|
|
|
AssertEqual &tw, 71
|
|
|
|
|
|
|
|
Do (A<Cr>):
|
|
|
|
A\<Cr>\<Esc>
|
|
|
|
|
|
|
|
Expect (Table Head \#891):
|
|
|
|
| foo | bar |
|
|
|
|
| | |
|
|
|
|
|
|
|
|
Execute (Assert tw=71):
|
|
|
|
AssertEqual &tw, 71
|
2019-12-15 05:37:28 +01:00
|
|
|
|
|
|
|
# Autoformat {{{1
|
|
|
|
#################
|
|
|
|
|
|
|
|
Given vimwiki (Unaligned table):
|
|
|
|
| title1 | title2 |
|
|
|
|
| - | - |
|
|
|
|
| a1 | b1 |
|
|
|
|
| a2 | |
|
|
|
|
|
|
|
|
Execute (Rename file wiki_test.md for table expand):
|
|
|
|
file wiki_test.md
|
|
|
|
|
|
|
|
Do (A to trigger insertLeave):
|
|
|
|
A
|
|
|
|
|
|
|
|
Expect (Table autoformat):
|
|
|
|
| title1 | title2 |
|
|
|
|
| - | - |
|
|
|
|
| a1 | b1 |
|
|
|
|
| a2 | |
|
|
|
|
|
|
|
|
Do (gqq to reformats table after making changes.):
|
|
|
|
gqq
|
|
|
|
|
|
|
|
Expect (Table autoformat):
|
|
|
|
| title1 | title2 |
|
|
|
|
| - | - |
|
|
|
|
| a1 | b1 |
|
|
|
|
| a2 | |
|
|
|
|
|
|
|
|
Execute (Option table_reduce_last_col = 1):
|
|
|
|
let g:vimwiki_global_vars['table_reduce_last_col'] = 1
|
|
|
|
|
|
|
|
Do (A to trigger insertLeave):
|
|
|
|
A
|
|
|
|
|
|
|
|
Expect (Last column not expanded):
|
|
|
|
| title1 | title2 |
|
|
|
|
| - | - |
|
|
|
|
| a1 | b1 |
|
|
|
|
| a2 | |
|
|
|
|
|
|
|
|
Execute (Option table_reduce_last_col = 0 [restore]):
|
|
|
|
let g:vimwiki_global_vars['table_reduce_last_col'] = 0
|
|
|
|
|
|
|
|
Execute (Option table_auto_fmt = 0):
|
|
|
|
let g:vimwiki_global_vars['table_auto_fmt'] = 0
|
|
|
|
|
|
|
|
Expect (Same as input):
|
|
|
|
| title1 | title2 |
|
|
|
|
| - | - |
|
|
|
|
| a1 | b1 |
|
|
|
|
| a2 | |
|
|
|
|
|
|
|
|
Execute (Option table_auto_fmt = 1 [restore]):
|
|
|
|
let g:vimwiki_global_vars['table_auto_fmt'] = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Move and edit cells {{{1
|
|
|
|
##########################
|
|
|
|
|
|
|
|
Do (Use <Tab> in insert mode):
|
|
|
|
GI
|
|
|
|
\<Tab>
|
|
|
|
this_is_16_chars
|
|
|
|
\<Tab>
|
|
|
|
this_is_16_chars
|
|
|
|
\<Esc>
|
|
|
|
|
|
|
|
Expect (Table autoformated with more content):
|
|
|
|
| title1 | title2 |
|
|
|
|
| - | - |
|
|
|
|
| a1 | b1 |
|
|
|
|
| this_is_16_charsa2 | this_is_16_chars |
|
|
|
|
|
|
|
|
Do (VimwikiTableMoveColumnRight):
|
|
|
|
gg:VimwikiTableMoveColumnRight\<CR>
|
|
|
|
|
|
|
|
Expect (Column inverted):
|
|
|
|
| title2 | title1 |
|
|
|
|
| - | - |
|
|
|
|
| b1 | a1 |
|
|
|
|
| | a2 |
|
|
|
|
|
|
|
|
Do (CR must insert new row):
|
|
|
|
GI\<Cr>a3
|
|
|
|
|
|
|
|
Expect (Table with new row starting by a3):
|
|
|
|
| title1 | title2 |
|
|
|
|
| - | - |
|
|
|
|
| a1 | b1 |
|
|
|
|
| a2 | |
|
|
|
|
| a3 | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# VimwikiTable Command {{{1
|
|
|
|
###########################
|
|
|
|
|
|
|
|
Given (Nothing):
|
|
|
|
|
|
|
|
Execute (VimwikiTable):
|
|
|
|
VimwikiTable
|
|
|
|
|
|
|
|
Expect (Table 5 x 2):
|
|
|
|
|
|
|
|
| | | | | |
|
|
|
|
|---|---|---|---|---|
|
|
|
|
| | | | | |
|
|
|
|
|
|
|
|
Execute (VimwikiTable 8 3):
|
|
|
|
VimwikiTable 8 3
|
|
|
|
|
|
|
|
Expect (Table 8 x 3):
|
|
|
|
|
|
|
|
| | | | | | | | |
|
|
|
|
|---|---|---|---|---|---|---|---|
|
|
|
|
| | | | | | | | |
|
|
|
|
| | | | | | | | |
|
|
|
|
|
|
|
|
|
2020-07-24 06:16:09 +02:00
|
|
|
Given vimwiki (Table 5 x (1+3)):
|
|
|
|
| h1 | h2 | h3 | h4 | h5 |
|
|
|
|
|-----|-----|-----|-----|-----|
|
|
|
|
| l11 | l12 | l13 | l14 | l15 |
|
|
|
|
| l21 | l22 | l23 | l24 | l25 |
|
|
|
|
| l31 | l32 | l33 | l34 | l35 |
|
|
|
|
|
|
|
|
Execute (VimwikiTableMoveColumnRight):
|
|
|
|
VimwikiTableMoveColumnRight
|
|
|
|
|
|
|
|
Expect (Col: 1 -> 2):
|
|
|
|
| h2 | h1 | h3 | h4 | h5 |
|
|
|
|
|-----|-----|-----|-----|-----|
|
|
|
|
| l12 | l11 | l13 | l14 | l15 |
|
|
|
|
| l22 | l21 | l23 | l24 | l25 |
|
|
|
|
| l32 | l31 | l33 | l34 | l35 |
|
|
|
|
|
|
|
|
Execute (VimwikiTableMoveColumnLeft):
|
|
|
|
call cursor(5, 16)
|
|
|
|
VimwikiTableMoveColumnLeft
|
|
|
|
|
|
|
|
Expect (Col: 3 -> 2):
|
|
|
|
| h1 | h3 | h2 | h4 | h5 |
|
|
|
|
|-----|-----|-----|-----|-----|
|
|
|
|
| l11 | l13 | l12 | l14 | l15 |
|
|
|
|
| l21 | l23 | l22 | l24 | l25 |
|
|
|
|
| l31 | l33 | l32 | l34 | l35 |
|
2019-12-15 05:37:28 +01:00
|
|
|
|
|
|
|
# Justify Cell Content {{{1
|
|
|
|
###########################
|
|
|
|
|
|
|
|
|
|
|
|
Given vimwiki (To be justified from help file [Coffe price]):
|
|
|
|
| Date | Item | Price |
|
|
|
|
|------------|:------:|--------:|
|
|
|
|
| yest |Coffee |$15.00 |
|
|
|
|
| 2017-02-13 |Tea |$2.10 |
|
|
|
|
| 2017-03-14 |Cake |$143.12 |
|
|
|
|
|
|
|
|
Execute (Rename file wiki_test.md for table expand):
|
|
|
|
file wiki_test.md
|
|
|
|
|
|
|
|
Do (A to trigger insertLeave):
|
|
|
|
A
|
|
|
|
|
|
|
|
Expect (Text justified):
|
|
|
|
| Date | Item | Price |
|
|
|
|
|------------|:------:|--------:|
|
|
|
|
| yest | Coffee | $15.00 |
|
|
|
|
| 2017-02-13 | Tea | $2.10 |
|
|
|
|
| 2017-03-14 | Cake | $143.12 |
|
|
|
|
|
2020-07-24 06:16:09 +02:00
|
|
|
Given vimwiki (To be left aligned):
|
|
|
|
| Date | Item |
|
|
|
|
|:------------|------:|
|
|
|
|
|yest|Coffee |
|
|
|
|
| 2017-02-13| Tea|
|
|
|
|
|2017-03-14 |Cake |
|
2019-12-15 05:37:28 +01:00
|
|
|
|
2020-07-24 06:16:09 +02:00
|
|
|
Do (A to trigger insertLeave):
|
|
|
|
A
|
|
|
|
|
|
|
|
Expect (Left justified and :--- -> ----):
|
|
|
|
| Date | Item |
|
|
|
|
|------------|-------:|
|
|
|
|
| yest | Coffee |
|
|
|
|
| 2017-02-13 | Tea |
|
|
|
|
| 2017-03-14 | Cake |
|
2019-12-15 05:37:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
# vim: foldmethod=marker foldlevel=30
|