mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-09 11:33:47 -05:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1bf139b30d | ||
|
|
b613e39bd0 | ||
|
|
7c56d298bb | ||
|
|
4cf1f53430 | ||
|
|
01289c0752 | ||
|
|
2ab64777a5 | ||
|
|
26b21e3454 | ||
|
|
fdfa4b12c2 | ||
|
|
e7373c9083 | ||
|
|
6872024827 | ||
|
|
50b3b01a33 | ||
|
|
5395c9f52b | ||
|
|
13d836dbfe | ||
|
|
b1e4041e43 | ||
|
|
bba1bf8d6e | ||
|
|
4baf9cfd2e | ||
|
|
8d2e013756 | ||
|
|
cc723fe8cd | ||
|
|
2c06812c39 |
@@ -1,5 +1,8 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## Version 4.6.4.1
|
||||||
|
* Added a fix for markdown commentstring
|
||||||
|
|
||||||
## Version 4.6.4
|
## Version 4.6.4
|
||||||
* Added support for center aligning columns
|
* Added support for center aligning columns
|
||||||
|
|
||||||
|
|||||||
109
README.md
109
README.md
@@ -1,14 +1,10 @@
|
|||||||
# VIM Table Mode v4.6.4 [](https://travis-ci.org/dhruvasagar/vim-table-mode)
|
# VIM Table Mode v4.6.4.1 [](https://travis-ci.org/dhruvasagar/vim-table-mode)
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
## Change Log
|
|
||||||
See <a
|
|
||||||
href="https://github.com/dhruvasagar/vim-table-mode/blob/master/CHANGELOG.md">
|
|
||||||
CHANGELOG.md </a>
|
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
There are several ways to do this
|
There are several ways to do this
|
||||||
@@ -30,29 +26,79 @@ $ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-m
|
|||||||
vimfiles/autoload/, vimfiles/plugin/ and vimfiles/doc under WINDOWS and
|
vimfiles/autoload/, vimfiles/plugin/ and vimfiles/doc under WINDOWS and
|
||||||
restart VIM
|
restart VIM
|
||||||
|
|
||||||
### Usage
|
### Creating table on-the-fly
|
||||||
|
|
||||||
- **On the fly table creation** :
|
To start using the plugin in the on-the-fly mode use `:TableModeToggle` mapped to <kbd>\<Leader\>tm</kbd> by default (which means <kbd>\\</kbd> <kbd>t</kbd> <kbd>m</kbd> if you didn't override the <Leader> by `:let mapleader = ","` to have <kbd>,</kbd> <kbd>t</kbd> <kbd>m</kbd>).
|
||||||
|
|
||||||
By default the table column separator is <kbd>|</kbd> defined by the
|
Enter the first line, delimiting columns by the `|` symbol. The plugin reacts by inserting spaces between the text and the separator if you omit them:
|
||||||
`g:table_mode_separator` option. As soon as you type it on a new line (ignores
|
|
||||||
indentation) the script gets to work on creating a table around it. As you
|
| name | address | phone |
|
||||||
type and define more columns, the table is completed, formatted and aligned
|
|
||||||
automatically on the fly.
|
In the second line (without leaving Insert mode), enter `|` twice. The plugin will write a properly formatted horizontal line:
|
||||||
|
|
||||||
|
| name | address | phone |
|
||||||
|
|------+---------+-------|
|
||||||
|
|
||||||
|
When you enter the subsequent lines, the plugin will automatically adjust the formatting to match the text you’re entering every time you press `|`:
|
||||||
|
|
||||||
|
| name | address | phone |
|
||||||
|
|------------+---------+-------|
|
||||||
|
| John Adams |
|
||||||
|
|
||||||
|
Go on until the table is ready:
|
||||||
|
|
||||||
|
| name | address | phone |
|
||||||
|
|-----------------+--------------------------+------------|
|
||||||
|
| John Adams | 1600 Pennsylvania Avenue | 0123456789 |
|
||||||
|
|-----------------+--------------------------+------------|
|
||||||
|
| Sherlock Holmes | 221B Baker Street | 0987654321 |
|
||||||
|
|-----------------+--------------------------+------------|
|
||||||
|
|
||||||
|
Then you can return to the first line and above it enter `||`:
|
||||||
|
|
||||||
|
|-----------------+--------------------------+------------|
|
||||||
|
| name | address | phone |
|
||||||
|
|-----------------+--------------------------+------------|
|
||||||
|
| John Adams | 1600 Pennsylvania Avenue | 0123456789 |
|
||||||
|
|-----------------+--------------------------+------------|
|
||||||
|
| Sherlock Holmes | 221B Baker Street | 0987654321 |
|
||||||
|
|-----------------+--------------------------+------------|
|
||||||
|
|
||||||
|
Corner separators are adjustable:
|
||||||
|
|
||||||
|
For Markdown-compatible tables use
|
||||||
|
|
||||||
|
let g:table_mode_corner="|"
|
||||||
|
|
||||||
|
|
||||||
|
|-----------------|--------------------------|------------|
|
||||||
|
| name | address | phone |
|
||||||
|
|-----------------|--------------------------|------------|
|
||||||
|
| John Adams | 1600 Pennsylvania Avenue | 0123456789 |
|
||||||
|
|-----------------|--------------------------|------------|
|
||||||
|
| Sherlock Holmes | 221B Baker Street | 0987654321 |
|
||||||
|
|-----------------|--------------------------|------------|
|
||||||
|
|
||||||
|
To get ReST-compatible tables use
|
||||||
|
|
||||||
|
let g:table_mode_corner_corner="+"
|
||||||
|
let g:table_mode_header_fillchar="="
|
||||||
|
|
||||||
|
|
||||||
|
+-----------------+--------------------------+------------+
|
||||||
|
| name | address | phone |
|
||||||
|
+=================+==========================+============+
|
||||||
|
| John Adams | 1600 Pennsylvania Avenue | 0123456789 |
|
||||||
|
+-----------------+--------------------------+------------+
|
||||||
|
| Sherlock Holmes | 221B Baker Street | 0987654321 |
|
||||||
|
+-----------------+--------------------------+------------+
|
||||||
|
|
||||||
Since this could lead to unwanted behavior I have disabled table mode by
|
|
||||||
default. You have to use `:TableModeToggle` command or the table mode
|
|
||||||
toggle mapping, which is <kbd>\<Leader\>tm</kbd> defined by `g:table_mode_toggle_map`
|
|
||||||
option to toggle the table mode or you can directly use `:TableModeEnable`
|
|
||||||
and `:TableModeDisable` to enable or disable the table mode. This is on a
|
|
||||||
per buffer basis and so it does not cause any unusual behavior unless it is
|
|
||||||
enabled explicitly. Please read `:h table-mode` for further information.
|
|
||||||
|
|
||||||
You can also define in a table header border how it's content should be
|
You can also define in a table header border how it's 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.
|
||||||
|
|
||||||
- **Format existing content into a table** :
|
### Formatting existing content into a table
|
||||||
|
|
||||||
Table Mode wouldn't justify it's name if it didn't allow formatting
|
Table Mode wouldn't justify it's name if it didn't allow formatting
|
||||||
existing content into a table. And it does as promised. Like table creation
|
existing content into a table. And it does as promised. Like table creation
|
||||||
@@ -74,7 +120,7 @@ $ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-m
|
|||||||
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.
|
||||||
|
|
||||||
- **Move between cells** :
|
### 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 |
|
||||||
@@ -82,7 +128,7 @@ $ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-m
|
|||||||
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** :
|
||||||
|
|
||||||
@@ -105,7 +151,9 @@ $ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-m
|
|||||||
(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.
|
||||||
|
|
||||||
- **Table Formulas** :
|
## Advanced Usage: Spreadsheet Capabilities
|
||||||
|
|
||||||
|
### 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 :
|
||||||
@@ -129,7 +177,7 @@ $ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-m
|
|||||||
|
|
||||||
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`.
|
||||||
|
|
||||||
@@ -170,10 +218,15 @@ $ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-m
|
|||||||
- `$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
|
||||||
|
|
||||||
<a href="http://www.youtube.com/watch?v=sK2IH1hiDkw"><img
|
<a href="http://www.youtube.com/watch?v=9lVQ0VJY3ps"><img
|
||||||
src="https://raw.github.com/dhruvasagar/vim-table-mode/master/youtube.png"/></a>
|
src="https://raw.github.com/axil/vim-table-mode/master/youtube.png"/></a>
|
||||||
|
|
||||||
|
## Change Log
|
||||||
|
See <a
|
||||||
|
href="https://github.com/dhruvasagar/vim-table-mode/blob/master/CHANGELOG.md">
|
||||||
|
CHANGELOG.md </a>
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ function! tablemode#spreadsheet#GetLastRow(line) "{{{2
|
|||||||
if tablemode#table#IsRow(a:line)
|
if tablemode#table#IsRow(a:line)
|
||||||
let line = tablemode#utils#line(a:line)
|
let line = tablemode#utils#line(a:line)
|
||||||
|
|
||||||
while tablemode#table#IsRow(line + 1) || tablemode#table#IsBorder(line + 1)
|
while tablemode#table#IsTable(line + 1)
|
||||||
let line += 1
|
let line += 1
|
||||||
endwhile
|
endwhile
|
||||||
if tablemode#table#IsBorder(line) | let line -= 1 | endif
|
if tablemode#table#IsBorder(line) | let line -= 1 | endif
|
||||||
@@ -61,7 +61,7 @@ function! tablemode#spreadsheet#LineNr(line, row) "{{{2
|
|||||||
let line = tablemode#spreadsheet#GetFirstRow(a:line)
|
let line = tablemode#spreadsheet#GetFirstRow(a:line)
|
||||||
let row_nr = 0
|
let row_nr = 0
|
||||||
|
|
||||||
while tablemode#table#IsRow(line + 1) || tablemode#table#IsBorder(line + 1)
|
while tablemode#table#IsTable(line + 1)
|
||||||
if tablemode#table#IsRow(line)
|
if tablemode#table#IsRow(line)
|
||||||
let row_nr += 1
|
let row_nr += 1
|
||||||
if a:row ==# row_nr | break | endif
|
if a:row ==# row_nr | break | endif
|
||||||
@@ -77,7 +77,7 @@ function! tablemode#spreadsheet#RowNr(line) "{{{2
|
|||||||
let line = tablemode#utils#line(a:line)
|
let line = tablemode#utils#line(a:line)
|
||||||
|
|
||||||
let rowNr = 0
|
let rowNr = 0
|
||||||
while !tablemode#table#IsHeader(line) && (tablemode#table#IsRow(line) || tablemode#table#IsBorder(line))
|
while !tablemode#table#IsHeader(line) && tablemode#table#IsTable(line)
|
||||||
if tablemode#table#IsRow(line) | let rowNr += 1 | endif
|
if tablemode#table#IsRow(line) | let rowNr += 1 | endif
|
||||||
let line -= 1
|
let line -= 1
|
||||||
endwhile
|
endwhile
|
||||||
@@ -89,13 +89,13 @@ function! tablemode#spreadsheet#RowCount(line) "{{{2
|
|||||||
let line = tablemode#utils#line(a:line)
|
let line = tablemode#utils#line(a:line)
|
||||||
|
|
||||||
let [tline, totalRowCount] = [line, 0]
|
let [tline, totalRowCount] = [line, 0]
|
||||||
while !tablemode#table#IsHeader(tline) && (tablemode#table#IsRow(tline) || tablemode#table#IsBorder(tline))
|
while !tablemode#table#IsHeader(tline) && tablemode#table#IsTable(tline)
|
||||||
if tablemode#table#IsRow(tline) | let totalRowCount += 1 | endif
|
if tablemode#table#IsRow(tline) | let totalRowCount += 1 | endif
|
||||||
let tline -= 1
|
let tline -= 1
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
let tline = line + 1
|
let tline = line + 1
|
||||||
while !tablemode#table#IsHeader(tline) && (tablemode#table#IsRow(tline) || tablemode#table#IsBorder(tline))
|
while !tablemode#table#IsHeader(tline) && tablemode#table#IsTable(tline)
|
||||||
if tablemode#table#IsRow(tline) | let totalRowCount += 1 | endif
|
if tablemode#table#IsRow(tline) | let totalRowCount += 1 | endif
|
||||||
let tline += 1
|
let tline += 1
|
||||||
endwhile
|
endwhile
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ function! tablemode#spreadsheet#cell#GetCells(line, ...) abort
|
|||||||
if row == 0
|
if row == 0
|
||||||
let values = []
|
let values = []
|
||||||
let line = first_row
|
let line = first_row
|
||||||
while tablemode#table#IsRow(line) || tablemode#table#IsBorder(line)
|
while tablemode#table#IsTable(line)
|
||||||
if tablemode#table#IsRow(line)
|
if tablemode#table#IsRow(line)
|
||||||
let row_line = getline(line)[stridx(getline(line), g:table_mode_separator):strridx(getline(line), g:table_mode_separator)]
|
let row_line = getline(line)[stridx(getline(line), g:table_mode_separator):strridx(getline(line), g:table_mode_separator)]
|
||||||
call add(values, tablemode#utils#strip(get(split(row_line, g:table_mode_separator), colm>0?colm-1:colm, '')))
|
call add(values, tablemode#utils#strip(get(split(row_line, g:table_mode_separator), colm>0?colm-1:colm, '')))
|
||||||
@@ -70,7 +70,7 @@ function! tablemode#spreadsheet#cell#GetCells(line, ...) abort
|
|||||||
let row_nr = 0
|
let row_nr = 0
|
||||||
let row_diff = row > 0 ? 1 : -1
|
let row_diff = row > 0 ? 1 : -1
|
||||||
let line = row > 0 ? first_row : last_row
|
let line = row > 0 ? first_row : last_row
|
||||||
while tablemode#table#IsRow(line) || tablemode#table#IsBorder(line)
|
while tablemode#table#IsTable(line)
|
||||||
if tablemode#table#IsRow(line)
|
if tablemode#table#IsRow(line)
|
||||||
let row_nr += row_diff
|
let row_nr += row_diff
|
||||||
if row ==# row_nr | break | endif
|
if row ==# row_nr | break | endif
|
||||||
|
|||||||
@@ -16,7 +16,10 @@ function! tablemode#spreadsheet#formula#Add(...) "{{{2
|
|||||||
if getline(fline) =~# 'tmf: '
|
if getline(fline) =~# 'tmf: '
|
||||||
" Comment line correctly
|
" Comment line correctly
|
||||||
let line_val = getline(fline)
|
let line_val = getline(fline)
|
||||||
let line_expr = line_val[match(line_val, tablemode#table#StartCommentExpr()):match(line_val, tablemode#table#EndCommentExpr())]
|
let start_pos = match(line_val, tablemode#table#StartCommentExpr())
|
||||||
|
let end_pos = match(line_val, tablemode#table#EndCommentExpr())
|
||||||
|
if empty(end_pos) | let end_pos = len(line_val) | endif
|
||||||
|
let line_expr = strpart(line_val, start_pos, end_pos)
|
||||||
let sce = matchstr(line_val, tablemode#table#StartCommentExpr() . '\zs')
|
let sce = matchstr(line_val, tablemode#table#StartCommentExpr() . '\zs')
|
||||||
let ece = matchstr(line_val, tablemode#table#EndCommentExpr())
|
let ece = matchstr(line_val, tablemode#table#EndCommentExpr())
|
||||||
call setline(fline, sce . line_expr . '; ' . fr . ece)
|
call setline(fline, sce . line_expr . '; ' . fr . ece)
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ endfunction
|
|||||||
function! tablemode#table#GetCommentStart() "{{{2
|
function! tablemode#table#GetCommentStart() "{{{2
|
||||||
let cstring = &commentstring
|
let cstring = &commentstring
|
||||||
if tablemode#utils#strlen(cstring) > 0
|
if tablemode#utils#strlen(cstring) > 0
|
||||||
return substitute(split(cstring, '%s')[0], '.', '\\\0', 'g')
|
return substitute(split(cstring, '%s')[0], '[^()]', '\\\0', 'g')
|
||||||
else
|
else
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
@@ -98,7 +98,7 @@ function! tablemode#table#GetCommentEnd() "{{{2
|
|||||||
if tablemode#utils#strlen(cstring) > 0
|
if tablemode#utils#strlen(cstring) > 0
|
||||||
let cst = split(cstring, '%s')
|
let cst = split(cstring, '%s')
|
||||||
if len(cst) == 2
|
if len(cst) == 2
|
||||||
return substitute(cst[1], '.', '\\\0', 'g')
|
return substitute(cst[1], '[^()]', '\\\0', 'g')
|
||||||
else
|
else
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
@@ -149,7 +149,11 @@ function! tablemode#table#IsHeader(line) "{{{2
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! tablemode#table#IsRow(line) "{{{2
|
function! tablemode#table#IsRow(line) "{{{2
|
||||||
return !tablemode#table#IsBorder(a:line) && getline(a:line) =~# (tablemode#table#StartExpr() . g:table_mode_separator)
|
return !tablemode#table#IsBorder(a:line) && getline(a:line) =~# (tablemode#table#StartExpr() . g:table_mode_separator) . '[^' . g:table_mode_separator . ']\+'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! tablemode#table#IsTable(line) "{{{2
|
||||||
|
return tablemode#table#IsRow(a:line) || tablemode#table#IsBorder(a:line)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! tablemode#table#AddBorder(line) "{{{2
|
function! tablemode#table#AddBorder(line) "{{{2
|
||||||
@@ -161,7 +165,7 @@ function! tablemode#table#Realign(line) "{{{2
|
|||||||
|
|
||||||
let lines = []
|
let lines = []
|
||||||
let [lnum, blines] = [line, []]
|
let [lnum, blines] = [line, []]
|
||||||
while tablemode#table#IsRow(lnum) || tablemode#table#IsBorder(lnum)
|
while tablemode#table#IsTable(lnum)
|
||||||
if tablemode#table#IsBorder(lnum)
|
if tablemode#table#IsBorder(lnum)
|
||||||
call insert(blines, lnum)
|
call insert(blines, lnum)
|
||||||
let lnum -= 1
|
let lnum -= 1
|
||||||
@@ -172,7 +176,7 @@ function! tablemode#table#Realign(line) "{{{2
|
|||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
let lnum = line + 1
|
let lnum = line + 1
|
||||||
while tablemode#table#IsRow(lnum) || tablemode#table#IsBorder(lnum)
|
while tablemode#table#IsTable(lnum)
|
||||||
if tablemode#table#IsBorder(lnum)
|
if tablemode#table#IsBorder(lnum)
|
||||||
call add(blines, lnum)
|
call add(blines, lnum)
|
||||||
let lnum += 1
|
let lnum += 1
|
||||||
|
|||||||
@@ -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.6.4
|
VERSION 4.6.4.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/>
|
||||||
@@ -86,7 +86,7 @@ Table Formulas:
|
|||||||
input formula will be appended to the formula line if one
|
input formula will be appended to the formula line if one
|
||||||
exists or a new one will be created with the input formula
|
exists or a new one will be created with the input formula
|
||||||
taking the current cell as the target cell. The formula line
|
taking the current cell as the target cell. The formula line
|
||||||
is evaluated immidiately to reflect the results.
|
is evaluated immediately to reflect the results.
|
||||||
|
|
||||||
You can directly also add / manipulate formula expressions in
|
You can directly also add / manipulate formula expressions in
|
||||||
the formula line. The formula line is a commented line right
|
the formula line. The formula line is a commented line right
|
||||||
@@ -349,6 +349,10 @@ MAPPINGS *table-mode-mappings*
|
|||||||
would evaluate the formula line and update the table
|
would evaluate the formula line and update the table
|
||||||
accordingly. This invokes the |TableEvalFormulaLine| command.
|
accordingly. This invokes the |TableEvalFormulaLine| command.
|
||||||
|
|
||||||
|
|
||||||
|
*table-mode-mappings-sort-column*
|
||||||
|
<Leader>ts Sort a column under the cursor. This invokes |TableSort|
|
||||||
|
|
||||||
|| Expands to a header border. You can change this by changing
|
|| Expands to a header border. You can change this by changing
|
||||||
|table-mode-separator| option. You can change the character to
|
|table-mode-separator| option. You can change the character to
|
||||||
be used for te extreme corners of the border by changing
|
be used for te extreme corners of the border by changing
|
||||||
@@ -416,6 +420,14 @@ COMMANDS *table-mode-commands*
|
|||||||
This command when invoked from anywhere within the table or directly
|
This command when invoked from anywhere within the table or directly
|
||||||
on the formula line evaluates it and updates the table accordingly.
|
on the formula line evaluates it and updates the table accordingly.
|
||||||
|
|
||||||
|
*:TableSort*
|
||||||
|
*table-mode-:TableSort*
|
||||||
|
:TableSort[!] [i][u][r][n][x][o]
|
||||||
|
This command sorts column under the cursor and inherits the same flags
|
||||||
|
as the |:sort| command.
|
||||||
|
|
||||||
|
With [!] the order is reversed.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
CONTRIBUTING *table-mode-contributing*
|
CONTRIBUTING *table-mode-contributing*
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ nnoremap <silent> <Plug>(table-mode-eval-formula) :call tablemode#spreadsheet#fo
|
|||||||
|
|
||||||
nnoremap <silent> <Plug>(table-mode-echo-cell) :call <SID>TableEchoCell()<CR>
|
nnoremap <silent> <Plug>(table-mode-echo-cell) :call <SID>TableEchoCell()<CR>
|
||||||
|
|
||||||
nnoremap <silent> <Plug>(table-mode-sort) :call tablemode#spreadsheet#Sort()<CR>
|
nnoremap <silent> <Plug>(table-mode-sort) :call tablemode#spreadsheet#Sort('')<CR>
|
||||||
|
|
||||||
if !hasmapto('<Plug>(table-mode-tableize)')
|
if !hasmapto('<Plug>(table-mode-tableize)')
|
||||||
exec "nmap " . g:table_mode_map_prefix . "t <Plug>(table-mode-tableize)"
|
exec "nmap " . g:table_mode_map_prefix . "t <Plug>(table-mode-tableize)"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ describe 'Formulas'
|
|||||||
call tablemode#spreadsheet#formula#Add("Sum(1:-1)")
|
call tablemode#spreadsheet#formula#Add("Sum(1:-1)")
|
||||||
Expect tablemode#spreadsheet#cell#GetCell() == '250.0'
|
Expect tablemode#spreadsheet#cell#GetCell() == '250.0'
|
||||||
call cursor(8, 15)
|
call cursor(8, 15)
|
||||||
Expect getline('.') == '/* tmf: $4,2=Sum(1:3) ; $5,2=Sum(1:-1) */'
|
Expect getline('.') == '/* tmf: $4,2=Sum(1:3); $5,2=Sum(1:-1) */'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
23
t/table.vim
23
t/table.vim
@@ -40,6 +40,29 @@ describe 'table'
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'IsTable'
|
||||||
|
before
|
||||||
|
new normal! ggdG
|
||||||
|
read t/fixtures/table/sample_with_header.txt
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should be true on a table row'
|
||||||
|
Expect tablemode#table#IsTable(2) to_be_true
|
||||||
|
Expect tablemode#table#IsTable(4) to_be_true
|
||||||
|
Expect tablemode#table#IsTable(5) to_be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should be true when on a table border'
|
||||||
|
Expect tablemode#table#IsTable(1) to_be_true
|
||||||
|
Expect tablemode#table#IsTable(3) to_be_true
|
||||||
|
Expect tablemode#table#IsTable(6) to_be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not be true when not on a table'
|
||||||
|
Expect tablemode#table#IsTable(7) to_be_false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'IsHeader'
|
describe 'IsHeader'
|
||||||
before
|
before
|
||||||
new
|
new
|
||||||
|
|||||||
BIN
youtube.png
BIN
youtube.png
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 43 KiB |
Reference in New Issue
Block a user