mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-08 11:03:47 -05:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10ab0425f6 | ||
|
|
e10a2ab4da | ||
|
|
496872f342 | ||
|
|
af432f6ed5 |
@@ -1,4 +1,8 @@
|
||||
# Change Log
|
||||
## Version 3.3.2
|
||||
* Added new mapping \t? to echo a cells representation for use while defining
|
||||
formulas.
|
||||
|
||||
## Version 3.3.1
|
||||
* Improved logic to ignore table borders (add as many as you'd like), the
|
||||
first row is not treated special, it is row # 1. Keep that in mind while
|
||||
|
||||
24
README.md
24
README.md
@@ -34,7 +34,7 @@ $ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-m
|
||||
|
||||
- **On the fly table creation** :
|
||||
|
||||
By default the table column separator is `|` defined by the
|
||||
By default the table column separator is <kbd>|</kbd> defined by the
|
||||
`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
|
||||
type and define more columns, the table is completed, formatted and aligned
|
||||
@@ -42,7 +42,7 @@ $ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-m
|
||||
|
||||
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 `<Leader>tm` defined by `g:table_mode_toggle_map`
|
||||
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
|
||||
@@ -54,25 +54,25 @@ $ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-m
|
||||
existing content into a table. And it does as promised. Like table creation
|
||||
on the fly as you type, formatting existing content into a table is equally
|
||||
simple. You can visually select multiple lines and call `:Tableize` on it,
|
||||
or alternatively use the mapping `<Leader>tt` defined by the
|
||||
or alternatively use the mapping <kbd>\<Leader\>tt</kbd> defined by the
|
||||
`g:table_mode_tableize_map` option which would convert CSV (Comma Separated
|
||||
Value) data into a table and use `,` defined by `g:table_mode_delimiter`
|
||||
option as the delimiter.
|
||||
|
||||
If however you wish to use a different delimiter, you can use the command
|
||||
`:Tableize/{pattern}` in a similar fashion as you use tabular (eg.
|
||||
`:Tableize/;` uses ';' as the delimiter) or use the mapping `<Leader>T`
|
||||
`:Tableize/;` uses ';' as the delimiter) or use the mapping <kbd>\<Leader\>T</kbd>
|
||||
defined by `g:table_mode_tableize_op_map` option which takes input in the
|
||||
cmd-line and uses the `{pattern}` input as the delimiter.
|
||||
|
||||
`:Tableize` also accepts a range and so you can also call it by giving
|
||||
lines manually like `:line1,line2Tableize`, but this is not very intuitive.
|
||||
You can use the mapping `<Leader>T` 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.
|
||||
|
||||
- **Move between cells** :
|
||||
|
||||
Now you can move between cells using table mode motions `<Leader>t[hjkl]`
|
||||
Now you can move between cells using table mode motions <kbd>\<Leader\>t[hjkl]</kbd>
|
||||
to move left | down | up | right cells respectively. You can use
|
||||
`g:table_mode_map_prefix` option to define the prefix mapping to be used
|
||||
before 'hjkl'. The left | right motions wrap around the table and move to
|
||||
@@ -84,7 +84,7 @@ $ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-m
|
||||
- **Cell Text Object** :
|
||||
|
||||
Tableize provides a text object for manipulating table cells. By default
|
||||
it's `tc`, but that can be changed if you wish to by setting the
|
||||
it's <kbd>tc</kbd>, but that can be changed if you wish to by setting the
|
||||
`g:table_mode_cell_text_object` option.
|
||||
|
||||
This is intelligent in the sense that if you use it to delete the
|
||||
@@ -98,14 +98,14 @@ $ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-m
|
||||
|
||||
- **Delete Row** :
|
||||
|
||||
You can use the `<Leader>tdd` 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
|
||||
you are within a table row), this can be preceeded with a [count] to
|
||||
delete multiple rows just like you would with 'dd'.
|
||||
|
||||
- **Delete Column** :
|
||||
|
||||
You can use the `<Leader>tdc` 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
|
||||
(provided you are within a table row), this can also be preceeded with a
|
||||
[count] to delete multiple columns.
|
||||
@@ -115,7 +115,7 @@ $ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-m
|
||||
Table Mode now has support for formulas like a spreadsheet. There are 2 ways
|
||||
of defining formulas :
|
||||
|
||||
- You can add formulas using `:TableAddFormula` or the mapping `<Leader>tfa`
|
||||
- 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
|
||||
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
|
||||
@@ -129,9 +129,11 @@ $ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-m
|
||||
formulas on the line separated with a ';' eg) `# tmf: $3=$2*$1;$4=$3/3.14`
|
||||
|
||||
You can evaluate the formula line using `:TableEvalFormulaLine` or the
|
||||
mapping `<Leader>tfe` 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.
|
||||
|
||||
NOTE: You can now use the mapping <kbd>\<Leader\>t?</kbd>
|
||||
|
||||
- **Formula Expressions** :
|
||||
|
||||
Expressions are of the format `$target = formula`.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
" Author: Dhruva Sagar <http://dhruvasagar.com/>
|
||||
" License: MIT (http://www.opensource.org/licenses/MIT)
|
||||
" Website: http://github.com/dhruvasagar/vim-table-mode
|
||||
" Version: 3.3.2
|
||||
" Version: 3.3.3
|
||||
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
|
||||
" (https://gist.github.com/tpope/287147) plugin by Tim Pope.
|
||||
"
|
||||
@@ -124,9 +124,9 @@ endfunction
|
||||
|
||||
function! s:HeaderBorderExpr() "{{{2
|
||||
return s:StartExpr() .
|
||||
\ '[' . g:table_mode_corner . g:table_mode_separator . ']' .
|
||||
\ '[' . g:table_mode_corner . g:table_mode_corner_corner . ']' .
|
||||
\ '[' . g:table_mode_fillchar . g:table_mode_corner . ']*' .
|
||||
\ '[' . g:table_mode_corner . g:table_mode_separator . ']' .
|
||||
\ '[' . g:table_mode_corner . g:table_mode_corner_corner . ']' .
|
||||
\ s:EndExpr()
|
||||
endfunction
|
||||
|
||||
@@ -180,7 +180,7 @@ endfunction
|
||||
|
||||
function! s:DefaultHeaderBorder() "{{{2
|
||||
if s:IsTableModeActive()
|
||||
return g:table_mode_separator . g:table_mode_fillchar . g:table_mode_corner . g:table_mode_fillchar . g:table_mode_separator
|
||||
return g:table_mode_corner_corner . g:table_mode_fillchar . g:table_mode_corner . g:table_mode_fillchar . g:table_mode_corner_corner
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
@@ -199,7 +199,7 @@ function! s:GenerateHeaderBorder(line) "{{{2
|
||||
if s:Strlen(line_val) <= 1 | return s:DefaultHeaderBorder() | endif
|
||||
let border = substitute(line_val[stridx(line_val, g:table_mode_separator):strridx(line_val, g:table_mode_separator)], g:table_mode_separator, g:table_mode_corner, 'g')
|
||||
let border = substitute(border, '[^' . g:table_mode_corner . ']', g:table_mode_fillchar, 'g')
|
||||
let border = substitute(border, '^' . g:table_mode_corner . '\(.*\)' . g:table_mode_corner . '$', g:table_mode_separator . '\1' . g:table_mode_separator , '')
|
||||
let border = substitute(border, '^' . g:table_mode_corner . '\(.*\)' . g:table_mode_corner . '$', g:table_mode_corner_corner . '\1' . g:table_mode_corner_corner, '')
|
||||
|
||||
let cstartexpr = s:StartCommentExpr()
|
||||
if s:Strlen(cstartexpr) > 0 && getline(line) =~# cstartexpr
|
||||
@@ -630,7 +630,10 @@ function! tablemode#GetFirstRow(line) "{{{2
|
||||
endfunction
|
||||
|
||||
function! tablemode#TableizeInsertMode() "{{{2
|
||||
if s:IsTableModeActive() && getline('.') =~# (s:StartExpr() . g:table_mode_separator)
|
||||
if s:IsTableModeActive() && getline('.') =~# (s:StartExpr() . g:table_mode_separator . g:table_mode_separator)
|
||||
call tablemode#AddHeaderBorder('.')
|
||||
normal! A
|
||||
elseif s:IsTableModeActive() && getline('.') =~# (s:StartExpr() . g:table_mode_separator)
|
||||
let column = s:Strlen(substitute(getline('.')[0:col('.')], '[^' . g:table_mode_separator . ']', '', 'g'))
|
||||
let position = s:Strlen(matchstr(getline('.')[0:col('.')], '.*' . g:table_mode_separator . '\s*\zs.*'))
|
||||
call tablemode#TableRealign('.')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
*table-mode.txt* Table Mode for easy table formatting. v3.3.2
|
||||
*table-mode.txt* Table Mode for easy table formatting. v3.3.3
|
||||
===============================================================================
|
||||
Table Mode, THE AWESOME AUTOMATIC TABLE CREATOR & FORMATTER
|
||||
VERSION 3.3.2
|
||||
VERSION 3.3.3
|
||||
|
||||
Author: Dhruva Sagar <http://dhruvasagar.com/>
|
||||
License: MIT <http://opensource.org/licenses/MIT/>
|
||||
@@ -148,6 +148,8 @@ Overview:
|
||||
current cell.
|
||||
|table-mode-eval-expr-map| ...... Evaluate formula line and update
|
||||
table.
|
||||
|table-mode-corner-corner| ...... Set the character to be used for
|
||||
extreme corners of the table border.
|
||||
|
||||
g:loaded_table_mode *table-mode-loaded*
|
||||
Use this option to disable the plugin: >
|
||||
@@ -277,6 +279,11 @@ g:table_mode_echo_cell_map *table-mode-echo-cell-map*
|
||||
representation for defining formulas. >
|
||||
let g:table_mode_echo_cell_map = '?'
|
||||
<
|
||||
g:table_mode_corner_corner *table-mode-corner-corner*
|
||||
Use this option to define the character to be used for the extreme
|
||||
corners of the table border. >
|
||||
let g:table_mode_corner_corner = '|'
|
||||
<
|
||||
|
||||
===============================================================================
|
||||
MAPPINGS *table-mode-mappings*
|
||||
@@ -332,9 +339,10 @@ MAPPINGS *table-mode-mappings*
|
||||
would evaluate the formula line and update the table
|
||||
accordingly. This invokes the |TableEvalFormulaLine| command.
|
||||
|
||||
|| Expands to a header border, the line immidiately above or
|
||||
below this will be considered as the table header. You can
|
||||
change this by changing |table-mode-separator| options.
|
||||
|| Expands to a header border. You can change this by changing
|
||||
|table-mode-separator| option. You can change the character to
|
||||
be used for te extreme corners of the border by changing
|
||||
|table-mode-corner-corner| option.
|
||||
|
||||
===============================================================================
|
||||
COMMANDS *table-mode-commands*
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
" Author: Dhruva Sagar <http://dhruvasagar.com/>
|
||||
" License: MIT (http://www.opensource.org/licenses/MIT)
|
||||
" Website: http://github.com/dhruvasagar/vim-table-mode
|
||||
" Version: 3.3.2
|
||||
" Version: 3.3.3
|
||||
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
|
||||
" (https://gist.github.com/tpope/287147) plugin by Tim Pope.
|
||||
"
|
||||
@@ -51,6 +51,7 @@ call s:SetGlobalOptDefault('table_mode_delete_column_map', 'dc')
|
||||
call s:SetGlobalOptDefault('table_mode_add_formula_map', 'fa')
|
||||
call s:SetGlobalOptDefault('table_mode_eval_expr_map', 'fe')
|
||||
call s:SetGlobalOptDefault('table_mode_echo_cell_map', '?')
|
||||
call s:SetGlobalOptDefault('table_mode_corner_corner', '|')
|
||||
|
||||
function! s:TableMotion() "{{{1
|
||||
let direction = nr2char(getchar())
|
||||
|
||||
@@ -14,6 +14,7 @@ let g:table_mode_delete_row_map = 'dd'
|
||||
let g:table_mode_delete_column_map = 'dc'
|
||||
let g:table_mode_add_formula_map = 'fa'
|
||||
let g:table_mode_eval_expr_map = 'fe'
|
||||
let g:table_mode_corner_corner = '|'
|
||||
|
||||
call vspec#hint({'scope': 'tablemode#scope()', 'sid': 'tablemode#sid()'})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user