mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-08 11:03:47 -05:00
Fixed Build Badge
This commit is contained in:
247
README.md
247
README.md
@@ -1,34 +1,39 @@
|
|||||||
# VIM Table Mode v4.8.0 [](https://travis-ci.org/dhruvasagar/vim-table-mode)
|
# VIM Table Mode v4.8.1 
|
||||||
|
|
||||||
An awesome automatic table creator & formatter allowing one to create neat
|
An awesome automatic table creator & formatter allowing one to create neat
|
||||||
tables as you type.
|
tables as you type.
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
#### <a href="https://www.danielfranklin.id.au/vim-8-package-management/">Vim 8+ native package manager</a>
|
#### <a href="https://www.danielfranklin.id.au/vim-8-package-management/">Vim 8+ native package manager</a>
|
||||||
clone into `.vim/pack/plugins/start` (the `plugins` folder can have any name)
|
|
||||||
|
clone into `.vim/pack/plugins/start` (the `plugins` folder can have any name)
|
||||||
Add `packloadall` in your `~/.vimrc`.
|
|
||||||
|
Add `packloadall` in your `~/.vimrc`.
|
||||||
|
|
||||||
#### <a href="https://github.com/Shougo/neobundle.vim">NeoBundle</a>
|
#### <a href="https://github.com/Shougo/neobundle.vim">NeoBundle</a>
|
||||||
Add `NeoBundle 'dhruvasagar/vim-table-mode'` to your `~/.vimrc`.
|
|
||||||
|
Add `NeoBundle 'dhruvasagar/vim-table-mode'` to your `~/.vimrc`.
|
||||||
|
|
||||||
#### <a href="https://github.com/tpope/vim-pathogen">pathogen.vim</a>
|
#### <a href="https://github.com/tpope/vim-pathogen">pathogen.vim</a>
|
||||||
Add a git submodule for your plugin:
|
|
||||||
|
Add a git submodule for your plugin:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ cd ~/.vim
|
$ cd ~/.vim
|
||||||
$ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-mode
|
$ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-mode
|
||||||
```
|
```
|
||||||
Copy all files under `autoload/`, `plugin/`, and `doc/` to respective
|
|
||||||
`~/.vim/autoload/`, `~/.vim/plugin` and `~/.vim/doc` under UNIX, or
|
Copy all files under `autoload/`, `plugin/`, and `doc/` to respective
|
||||||
`vimfiles/autoload/`, `vimfiles/plugin/` and `vimfiles/doc` under WINDOWS and
|
`~/.vim/autoload/`, `~/.vim/plugin` and `~/.vim/doc` under UNIX, or
|
||||||
restart Vim.
|
`vimfiles/autoload/`, `vimfiles/plugin/` and `vimfiles/doc` under WINDOWS and
|
||||||
|
restart Vim.
|
||||||
|
|
||||||
#### <a href="https://github.com/junegunn/vim-plug">vim-plug</a>
|
#### <a href="https://github.com/junegunn/vim-plug">vim-plug</a>
|
||||||
Add `Plug 'dhruvasagar/vim-table-mode'` to your `~/.vimrc`.
|
|
||||||
|
Add `Plug 'dhruvasagar/vim-table-mode'` to your `~/.vimrc`.
|
||||||
|
|
||||||
### Creating table on-the-fly
|
### Creating table on-the-fly
|
||||||
|
|
||||||
@@ -36,6 +41,7 @@ To start using the plugin in the on-the-fly mode use `:TableModeToggle` mapped t
|
|||||||
|
|
||||||
Tip:
|
Tip:
|
||||||
You can use the following to quickly enable / disable table mode in insert mode by using `||` or `__`:
|
You can use the following to quickly enable / disable table mode in insert mode by using `||` or `__`:
|
||||||
|
|
||||||
> ```vim
|
> ```vim
|
||||||
> function! s:isAtStartOfLine(mapping)
|
> function! s:isAtStartOfLine(mapping)
|
||||||
> let text_before_cursor = getline('.')[0 : col('.')-1]
|
> let text_before_cursor = getline('.')[0 : col('.')-1]
|
||||||
@@ -43,7 +49,7 @@ You can use the following to quickly enable / disable table mode in insert mode
|
|||||||
> let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\')
|
> let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\')
|
||||||
> return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$')
|
> return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$')
|
||||||
> endfunction
|
> endfunction
|
||||||
>
|
>
|
||||||
> inoreabbrev <expr> <bar><bar>
|
> inoreabbrev <expr> <bar><bar>
|
||||||
> \ <SID>isAtStartOfLine('\|\|') ?
|
> \ <SID>isAtStartOfLine('\|\|') ?
|
||||||
> \ '<c-o>:TableModeEnable<cr><bar><space><bar><left><left>' : '<bar><bar>'
|
> \ '<c-o>:TableModeEnable<cr><bar><space><bar><left><left>' : '<bar><bar>'
|
||||||
@@ -119,16 +125,16 @@ Markdown and ReST filetypes have automatically configured corners.
|
|||||||
|
|
||||||
> If you wish to override their configurations, it should be done in an after
|
> If you wish to override their configurations, it should be done in an after
|
||||||
> plugin, for example :
|
> plugin, for example :
|
||||||
>
|
>
|
||||||
> In a `$VIM/after/ftplugin/markdown/custom.vim` you can add the following :
|
> In a `$VIM/after/ftplugin/markdown/custom.vim` you can add the following :
|
||||||
>
|
>
|
||||||
> ```viml
|
> ```viml
|
||||||
> let b:table_mode_corner='+'
|
> let b:table_mode_corner='+'
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
You can also define in a table header border how its content should be
|
You can also define in a table header border how its content should be
|
||||||
aligned, whether center, right or left by using a `:` character defined by
|
aligned, whether center, right or left by using a `:` character defined by
|
||||||
`g:table_mode_align_char` option.
|
`g:table_mode_align_char` option.
|
||||||
|
|
||||||
If you manipulate the table when table mode is disabled or copy paste a table
|
If you manipulate the table when table mode is disabled or copy paste a table
|
||||||
from clipboard from outside and it ends up being misaligned, you can realign
|
from clipboard from outside and it ends up being misaligned, you can realign
|
||||||
@@ -137,144 +143,139 @@ it using `:TableModeRealign` or using the default mapping
|
|||||||
|
|
||||||
### Formatting existing content into a table
|
### Formatting existing content into a table
|
||||||
|
|
||||||
Table Mode wouldn't justify its name if it didn't allow formatting
|
Table Mode wouldn't justify its name if it didn't allow formatting
|
||||||
existing content into a table. And it does as promised. Like table creation typing on the fly,
|
existing content into a table. And it does as promised. Like table creation typing on the fly,
|
||||||
formatting existing content into a table is equally
|
formatting existing content into a table is equally
|
||||||
simple. You can visually select multiple lines and call `:Tableize` on it.
|
simple. You can visually select multiple lines and call `:Tableize` on it.
|
||||||
Alternatively, the mapping <kbd>\<Leader\>tt</kbd> can be used (defined by the
|
Alternatively, the mapping <kbd>\<Leader\>tt</kbd> can be used (defined by the
|
||||||
option `g:table_mode_tableize_map`). This converts CSV (Comma-separated
|
option `g:table_mode_tableize_map`). This converts CSV (Comma-separated
|
||||||
Values) data into a table.
|
Values) data into a table.
|
||||||
|
|
||||||
If however you wish to use a different delimiter, you can use the command
|
If however you wish to use a different delimiter, you can use the command
|
||||||
`:Tableize/{pattern}` in a similar fashion as you tabulate (e.g.
|
`:Tableize/{pattern}` in a similar fashion as you tabulate (e.g.
|
||||||
`:Tableize/;` uses ';' as the delimiter) or use the mapping <kbd>\<Leader\>T</kbd>
|
`:Tableize/;` uses ';' as the delimiter) or use the mapping <kbd>\<Leader\>T</kbd>
|
||||||
(defined by the option `g:table_mode_tableize_op_map`) which takes input in the
|
(defined by the option `g:table_mode_tableize_op_map`) which takes input in the
|
||||||
cmd-line and uses the `{pattern}` input as the delimiter.
|
cmd-line and uses the `{pattern}` input as the delimiter.
|
||||||
|
|
||||||
`:Tableize` also accepts a range. Call it by giving
|
`:Tableize` also accepts a range. Call it by giving
|
||||||
lines manually like `:line1,line2Tableize`. However this may not be intuitive.
|
lines manually like `:line1,line2Tableize`. However this may not be intuitive.
|
||||||
You can use the mapping <kbd>\<Leader\>T</kbd> with a `[count]` to apply it to the
|
You can use the mapping <kbd>\<Leader\>T</kbd> with a `[count]` to apply it to the
|
||||||
next `[count]` lines in standard vim style.
|
next `[count]` lines in standard vim style.
|
||||||
|
|
||||||
### Moving around
|
### Moving around
|
||||||
|
|
||||||
Now you can move between cells using table mode motions <kbd>[|</kbd>,
|
Now you can move between cells using table mode motions <kbd>[|</kbd>,
|
||||||
<kbd>]|</kbd>, <kbd>{|</kbd> & <kbd>}|</kbd> to move left | right | up |
|
<kbd>]|</kbd>, <kbd>{|</kbd> & <kbd>}|</kbd> to move left | right | up |
|
||||||
down cells respectively. The left | right motions wrap around the table
|
down cells respectively. The left | right motions wrap around the table
|
||||||
and move to the next | previous row after the last | first cell in the
|
and move to the next | previous row after the last | first cell in the
|
||||||
current row if one exists.
|
current row if one exists.
|
||||||
|
|
||||||
### Manipulating Table
|
### Manipulating Table
|
||||||
|
|
||||||
- **Cell Text Object** :
|
- **Cell Text Object** :
|
||||||
|
|
||||||
Tableize provides a text object for manipulating table cells. Following
|
Tableize provides a text object for manipulating table cells. Following
|
||||||
the vim philosophy the you have <kbd>i|</kbd> & <kbd>a|</kbd> for the
|
the vim philosophy the you have <kbd>i|</kbd> & <kbd>a|</kbd> for the
|
||||||
inner and around (including the immediate right table separator) the
|
inner and around (including the immediate right table separator) the
|
||||||
table cell.
|
table cell.
|
||||||
|
|
||||||
- **Delete Row** :
|
- **Delete Row** :
|
||||||
|
|
||||||
You can use the <kbd>\<Leader\>tdd</kbd> mapping (defined by the option
|
You can use the <kbd>\<Leader\>tdd</kbd> mapping (defined by the option
|
||||||
`g:table_mode_delete_row_map`) to delete the current table row (provided
|
`g:table_mode_delete_row_map`) to delete the current table row (provided
|
||||||
you are within a table row). This can be preceeded with a `[count]` to
|
you are within a table row). This can be preceeded with a `[count]` to
|
||||||
delete multiple rows as per Vim command grammar.
|
delete multiple rows as per Vim command grammar.
|
||||||
|
|
||||||
- **Delete Column** :
|
- **Delete Column** :
|
||||||
|
|
||||||
You can use the <kbd>\<Leader\>tdc</kbd> mapping (defined by the option
|
You can use the <kbd>\<Leader\>tdc</kbd> mapping (defined by the option
|
||||||
`g:table_mode_delete_column_map`) to delete the entire current column
|
`g:table_mode_delete_column_map`) to delete the entire current column
|
||||||
(provided you are within a table row), this can also be preceeded with a
|
(provided you are within a table row), this can also be preceeded with a
|
||||||
`[count]` to delete multiple columns.
|
`[count]` to delete multiple columns.
|
||||||
|
|
||||||
- **Insert Column** :
|
- **Insert Column** :
|
||||||
|
|
||||||
You can use the <kbd>\<Leader\>tic</kbd> mapping (defined by the option
|
You can use the <kbd>\<Leader\>tic</kbd> mapping (defined by the option
|
||||||
`g:table_mode_insert_column_after_map`) to insert a column after the
|
`g:table_mode_insert_column_after_map`) to insert a column after the
|
||||||
cursor (provided you are within a table row). Of course you can use the
|
cursor (provided you are within a table row). Of course you can use the
|
||||||
<kbd>\<Leader\>tiC</kbd> mapping defined by
|
<kbd>\<Leader\>tiC</kbd> mapping defined by
|
||||||
`g:table_mode_insert_column_before_map` to insert a column before the
|
`g:table_mode_insert_column_before_map` to insert a column before the
|
||||||
cursor. Both can also be preceeded with a [count] to insert multiple
|
cursor. Both can also be preceeded with a [count] to insert multiple
|
||||||
columns.
|
columns.
|
||||||
|
|
||||||
### Highlight cells based on content
|
### Highlight cells based on content
|
||||||
|
|
||||||
You can highlight cells based on content by setting `let g:table_mode_color_cells` :
|
You can highlight cells based on content by setting `let g:table_mode_color_cells` : - cells starting with `yes` will use the `yesCell` highlight group. - cells starting with `no` will use the `noCell` highlight group. - cells starting with `?` will use the `maybeCell` hightlight group.
|
||||||
- cells starting with `yes` will use the `yesCell` highlight group.
|
|
||||||
- cells starting with `no` will use the `noCell` highlight group.
|
|
||||||
- cells starting with `?` will use the `maybeCell` hightlight group.
|
|
||||||
|
|
||||||
You can overwrite any highlight group. For exemple use `hi yesCell ctermfg=2` to remove the background color.
|
|
||||||
|
|
||||||
|
|
||||||
|
You can overwrite any highlight group. For exemple use `hi yesCell ctermfg=2` to remove the background color.
|
||||||
|
|
||||||
## Advanced Usage: Spreadsheet Capabilities
|
## Advanced Usage: Spreadsheet Capabilities
|
||||||
|
|
||||||
### Table Formulas
|
### Table Formulas
|
||||||
|
|
||||||
Table Mode now has support for formulas like a spreadsheet. There are 2 ways
|
Table Mode now has support for formulas like a spreadsheet. There are 2 ways
|
||||||
of defining formulas :
|
of defining formulas :
|
||||||
|
|
||||||
- You can add formulas using `:TableAddFormula` or the mapping <kbd>\<Leader\>tfa</kbd>
|
- You can add formulas using `:TableAddFormula` or the mapping <kbd>\<Leader\>tfa</kbd>
|
||||||
(defined by the option `g:table_mode_add_formula_map`) from within a table
|
(defined by the option `g:table_mode_add_formula_map`) from within a table
|
||||||
cell, which will ask for input on the cmd-line with a `f=` prompt. The
|
cell, which will ask for input on the cmd-line with a `f=` prompt. The
|
||||||
input formula will be appended to the formula line if one exists or a new
|
input formula will be appended to the formula line if one exists or a new
|
||||||
one will be created with the input formula taking the current cell as the
|
one will be created with the input formula taking the current cell as the
|
||||||
target cell. The formula line is evaluated immidiately to reflect the
|
target cell. The formula line is evaluated immidiately to reflect the
|
||||||
results.
|
results.
|
||||||
|
|
||||||
- You can directly add / manipulate formula expressions in the formula line.
|
- You can directly add / manipulate formula expressions in the formula line.
|
||||||
The formula line is a commented line right after the table, or optionally
|
The formula line is a commented line right after the table, or optionally
|
||||||
separated from the table by a single empty line. It begins with 'tmf:'
|
separated from the table by a single empty line. It begins with 'tmf:'
|
||||||
(table mode formula). eg) `# tmf: $3=$2*$1`. You can add multiple formulas on
|
(table mode formula). eg) `# tmf: $3=$2*$1`. You can add multiple formulas on
|
||||||
the line separated with a ';' eg) `# tmf: $3=$2*$1;$4=$3/3.14`
|
the line separated with a ';' eg) `# tmf: $3=$2*$1;$4=$3/3.14`
|
||||||
|
|
||||||
You can evaluate the formula line using `:TableEvalFormulaLine` or the
|
You can evaluate the formula line using `:TableEvalFormulaLine` or the
|
||||||
mapping <kbd>\<Leader\>tfe</kbd> (defined by the option `g:table_mode_eval_expr_map`)
|
mapping <kbd>\<Leader\>tfe</kbd> (defined by the option `g:table_mode_eval_expr_map`)
|
||||||
from anywhere inside the table or while on the formula line.
|
from anywhere inside the table or while on the formula line.
|
||||||
|
|
||||||
NOTE: You can now use the mapping <kbd>\<Leader\>t?</kbd>
|
NOTE: You can now use the mapping <kbd>\<Leader\>t?</kbd>
|
||||||
|
|
||||||
### Formula Expressions
|
### Formula Expressions
|
||||||
|
|
||||||
Expressions are of the format `$target = formula`.
|
Expressions are of the format `$target = formula`.
|
||||||
|
|
||||||
- The `target` can be of 2 forms :
|
- The `target` can be of 2 forms :
|
||||||
|
|
||||||
- `$n`: This matches the table column number `n`. So the `formula` would
|
- `$n`: This matches the table column number `n`. So the `formula` would
|
||||||
be evaluated for each cell in that column and the result would be placed
|
be evaluated for each cell in that column and the result would be placed
|
||||||
in it. You can use negative indice to represent column relative to the
|
in it. You can use negative indice to represent column relative to the
|
||||||
last, -1 being the last.
|
last, -1 being the last.
|
||||||
|
|
||||||
- `$n,m`: This matches the table cell n,m (row, column). So in this case
|
- `$n,m`: This matches the table cell n,m (row, column). So in this case
|
||||||
the formula would be evaluated and the result will be placed in this
|
the formula would be evaluated and the result will be placed in this
|
||||||
cell. You can also use negative values to refer to cells relative to
|
cell. You can also use negative values to refer to cells relative to
|
||||||
the size, -1 being the last (row or column).
|
the size, -1 being the last (row or column).
|
||||||
|
|
||||||
- The `formula` can be a simple mathematical expression involving cells
|
- The `formula` can be a simple mathematical expression involving cells
|
||||||
which are also defined by the same format as that of the target cell. You
|
which are also defined by the same format as that of the target cell. You
|
||||||
can use all native vim functions within the formula. Apart from that table
|
can use all native vim functions within the formula. Apart from that table
|
||||||
mode also provides 2 special functions `Sum` and `Average`. Both these
|
mode also provides 2 special functions `Sum` and `Average`. Both these
|
||||||
functions take a range as input. A range can be of two forms:
|
functions take a range as input. A range can be of two forms:
|
||||||
|
|
||||||
- `r1:r2`: This represents cells in the current column from row `r1`
|
- `r1:r2`: This represents cells in the current column from row `r1`
|
||||||
through `r2`. If `r2` is negative it represents `r2` rows above the
|
through `r2`. If `r2` is negative it represents `r2` rows above the
|
||||||
current row (of the target cell).
|
current row (of the target cell).
|
||||||
|
|
||||||
- `r1,c1:r2,c2`: This represents cells in the table from cell r1,c1
|
- `r1,c1:r2,c2`: This represents cells in the table from cell r1,c1
|
||||||
through cell r2,c2 (row, column).
|
through cell r2,c2 (row, column).
|
||||||
|
|
||||||
- Examples :
|
- Examples :
|
||||||
- `$2 = $1 * $1`
|
- `$2 = $1 * $1`
|
||||||
- `$2 = pow($1, 5)` NOTE: Remember to put space between the $1, and 5
|
- `$2 = pow($1, 5)` NOTE: Remember to put space between the $1, and 5
|
||||||
here otherwise it will be treated like a table cell.
|
here otherwise it will be treated like a table cell.
|
||||||
- `$2 = $1 / $1,3`
|
- `$2 = $1 / $1,3`
|
||||||
- `$1,2 = $1,1 * $1,1`
|
- `$1,2 = $1,1 * $1,1`
|
||||||
- `$5,1 = Sum(1:-1)`
|
- `$5,1 = Sum(1:-1)`
|
||||||
- `$5,1 = float2nr(Sum(1:-1))`
|
- `$5,1 = float2nr(Sum(1:-1))`
|
||||||
- `$5,3 = Sum(1,2:5,2)`
|
- `$5,3 = Sum(1,2:5,2)`
|
||||||
- `$5,3 = Sum(1,2:5,2)/$5,1`
|
- `$5,3 = Sum(1,2:5,2)/$5,1`
|
||||||
- `$5,3 = Average(1,2:5,2)/$5,1`
|
- `$5,3 = Average(1,2:5,2)/$5,1`
|
||||||
|
|
||||||
## Demo
|
## Demo
|
||||||
|
|
||||||
@@ -282,6 +283,7 @@ it using `:TableModeRealign` or using the default mapping
|
|||||||
src="https://raw.github.com/axil/vim-table-mode/master/youtube.png"/></a>
|
src="https://raw.github.com/axil/vim-table-mode/master/youtube.png"/></a>
|
||||||
|
|
||||||
## Change Log
|
## Change Log
|
||||||
|
|
||||||
See <a
|
See <a
|
||||||
href="https://github.com/dhruvasagar/vim-table-mode/blob/master/CHANGELOG.md">
|
href="https://github.com/dhruvasagar/vim-table-mode/blob/master/CHANGELOG.md">
|
||||||
CHANGELOG.md </a>
|
CHANGELOG.md </a>
|
||||||
@@ -289,16 +291,19 @@ CHANGELOG.md </a>
|
|||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
### Reporting an Issue :
|
### Reporting an Issue :
|
||||||
|
|
||||||
- Use <a href="https://github.com/dhruvasagar/vim-table-mode/issues">Github
|
- Use <a href="https://github.com/dhruvasagar/vim-table-mode/issues">Github
|
||||||
Issue Tracker</a>
|
Issue Tracker</a>
|
||||||
|
|
||||||
### Contributing to code :
|
### Contributing to code :
|
||||||
|
|
||||||
- Fork it.
|
- Fork it.
|
||||||
- Commit your changes and give your commit message some love.
|
- Commit your changes and give your commit message some love.
|
||||||
- Push to your fork on github.
|
- Push to your fork on github.
|
||||||
- Open a Pull Request.
|
- Open a Pull Request.
|
||||||
|
|
||||||
## Credit
|
## Credit
|
||||||
|
|
||||||
I must thank Tim Pope for inspiration. The initial concept was created by him
|
I must thank Tim Pope for inspiration. The initial concept was created by him
|
||||||
named <a href="https://gist.github.com/tpope/287147">cucumbertables.vim</a>.
|
named <a href="https://gist.github.com/tpope/287147">cucumbertables.vim</a>.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
*table-mode.txt* Table Mode for easy table formatting
|
*table-mode.txt* Table Mode for easy table formatting
|
||||||
===============================================================================
|
===============================================================================
|
||||||
Table Mode, THE AWESOME AUTOMATIC TABLE CREATOR & FORMATTER
|
Table Mode, THE AWESOME AUTOMATIC TABLE CREATOR & FORMATTER
|
||||||
VERSION 4.8.0
|
VERSION 4.8.1
|
||||||
|
|
||||||
Author: Dhruva Sagar <http://dhruvasagar.com/>
|
Author: Dhruva Sagar <http://dhruvasagar.com/>
|
||||||
License: MIT <http://opensource.org/licenses/MIT/>
|
License: MIT <http://opensource.org/licenses/MIT/>
|
||||||
@@ -544,4 +544,3 @@ REPORT ISSUES *table-mode-report-issues*
|
|||||||
|
|
||||||
If you discover any issues, please report them at
|
If you discover any issues, please report them at
|
||||||
http://github.com/dhruvasagar/vim-table-mode/issues.
|
http://github.com/dhruvasagar/vim-table-mode/issues.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user