-
Notifications
You must be signed in to change notification settings - Fork 2
Provide handy shortcuts for :Tabular #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -359,6 +359,42 @@ There are also two shorthands for adding the attributes `options=""` and `cols=" | |
| With the cursor inside the table, kbd:[+,cols+] adds the latter and kbd:[+,opts+] the former. | ||
|
|
||
|
|
||
| ==== Aligning | ||
|
|
||
| When the https://github.com/godlygeek/tabular[Tabular Plugin] is | ||
| installed (which is highly recommended when working with tables), | ||
| alignment of tables is possible via kbd:[+,|+]. This applies only to tables | ||
| that use the Bar kbd:[+|+] as separator between cells. | ||
|
|
||
| Be aware that this only works for basic tables and certain features like | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you really want the user to be aware, use an admonition. I am not sure what "the cell spanning will not be visualized in the asciidoc sourcecode" means. |
||
| cell spanning do not work well with it together. It won't break the table, | ||
| but the cell spanning will not be visualized in the asciidoc sourcecode. | ||
|
|
||
| .Before | ||
| .... | ||
| [%header] | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The % stuff is a nice feature but it's only noise in this context. I don't see how this adds any value for the reader. If it does it should be added in one fell swoop everywhere. |
||
| |=== | ||
| |Animal|Color|Food | ||
| |Chicken|white|mostlycrop | ||
| |Pig|rose|everything | ||
| |=== | ||
| .... | ||
|
|
||
| .After | ||
| .... | ||
| [%header] | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above |
||
| |=== | ||
| | Animal | Color | Food | ||
| | Chicken | white | mostly crop | ||
| | Pig | rose | everything | ||
| |=== | ||
| .... | ||
|
|
||
| If the option `g:asciidoc_table_autoalign` is set to 1 (which is set to 0 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One sentence per line. |
||
| by default) a function will be enabled that autoaligns a table each time | ||
| the Bar kbd:[+|+] is entered inside the table. | ||
|
|
||
|
|
||
| [[editing-motions]] | ||
| === Motions | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -72,6 +72,11 @@ if -1 < match(g:asciidoc_use_defaults, 'options') | |||||
| let g:asciidoc_debug_level = 0 | ||||||
| endif | ||||||
|
|
||||||
| if !exists('g:asciidoc_table_autoalign') | ||||||
| " do not autoalign table cells by default | ||||||
| let g:asciidoc_table_autoalign = 0 | ||||||
| endif | ||||||
|
|
||||||
| setlocal commentstring=//\ %s | ||||||
| setlocal comments=fl:////,://,fn:*,fn:. | ||||||
| setlocal formatoptions=tcqjnro | ||||||
|
|
@@ -375,4 +380,26 @@ nnoremap <buffer> <silent> <LocalLeader>dsb :call asciidoc#experimental#delete_s | |||||
|
|
||||||
| " }}} | ||||||
|
|
||||||
| " Tabular ================================================== {{{ | ||||||
| if exists(':Tabularize') | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you thought about the options here? |
||||||
| " Use <Leader>| to realign tables with the Tabuliarize plugin | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| nnoremap <buffer> <LocalLeader><Bar> :Tabularize /<Bar>\(===\)\@!<CR> " we need a negative lookahead to avoid breaking the block delimiters | ||||||
| vnoremap <buffer> <LocalLeader><Bar> :Tabularize /<Bar>\(===\)\@!<CR> " we need a negative lookahead to avoid breaking the block delimiters | ||||||
|
|
||||||
| " Realign table when entering a | | ||||||
| if g:asciidoc_table_autoalign == 1 | ||||||
| inoremap <buffer> <Bar> <Bar><Esc>:call <SID>align()<CR>a | ||||||
| function! s:align() | ||||||
| if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# '^\s*|' || getline(line('.')+1) =~# '^\s*|') | ||||||
| let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g')) | ||||||
| let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*')) | ||||||
| Tabularize /|\(=\)\@! | ||||||
| normal! 0 | ||||||
| call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.')) | ||||||
| endif | ||||||
| endfunction | ||||||
| endif | ||||||
| endif | ||||||
| " }}} | ||||||
|
|
||||||
| " vim: set fdm=marker: | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One sentence per line.
,splplsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And lvl2 is to communicate "one idea per sentence".
If Tabular is highly recommended, it deserves it's own sentence.
Don't squeeze it into a parenthesis in the middle of a sentence.
Doing so interferes with the thought communicated in the surrounding sentence.
Suggest something like: