mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-09 03:23:47 -05:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63cb175d57 | ||
|
|
4eae4a659d | ||
|
|
5012486cbe | ||
|
|
12f4c39982 | ||
|
|
943496c535 | ||
|
|
151d489a53 | ||
|
|
aa5b5ef526 | ||
|
|
a0207b7895 |
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,4 +1,15 @@
|
||||
# Change Log
|
||||
## Version 4.1.0
|
||||
* Fixed bad references within plugin
|
||||
* Added fixtures
|
||||
|
||||
## Version 4.0.0
|
||||
* Major refactoring of the codebase.
|
||||
* Improved modular tests.
|
||||
* Fixed long standing unicode character alignment issue.
|
||||
* Moved to providing <Plug> mappings rather than configuration based mappings
|
||||
which can be more easily overriden by end user.
|
||||
|
||||
## Version 3.3.2
|
||||
* Added new mapping \t? to echo a cells representation for use while defining
|
||||
formulas.
|
||||
|
||||
29
README.md
29
README.md
@@ -1,4 +1,4 @@
|
||||
# VIM Table Mode [](https://travis-ci.org/dhruvasagar/vim-table-mode)
|
||||
# VIM Table Mode v4.1.0 [](https://travis-ci.org/dhruvasagar/vim-table-mode)
|
||||
|
||||
An awesome automatic table creator & formatter allowing one to create neat
|
||||
tables as you type.
|
||||
@@ -72,29 +72,20 @@ $ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-m
|
||||
|
||||
- **Move between cells** :
|
||||
|
||||
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
|
||||
the next | previous row after the last | first cell in the current row if
|
||||
one exists.
|
||||
Now you can move between cells using table mode motions <kbd>[|</kbd>,
|
||||
<kbd>]|</kbd>, <kbd>{|</kbd> & <kbd>}|</kbd> to move left | right | up |
|
||||
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
|
||||
current row if one exists.
|
||||
|
||||
- **Manipulating Table** :
|
||||
|
||||
- **Cell Text Object** :
|
||||
|
||||
Tableize provides a text object for manipulating table cells. By default
|
||||
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
|
||||
contents it will delete everything till the `g:table_mode_separator` so
|
||||
that the cell is removed and you can enter new stuff if you wish to (had
|
||||
you used 'c' operator), having to input the `g:table_mode_separator`
|
||||
again to form the cell & realign it (since it can't be done from the
|
||||
text object itself). However if you were to 'y' or yank the text, it
|
||||
would copy the right text, i.e. the contents of the cell and nothing
|
||||
else.
|
||||
Tableize provides a text object for manipulating table cells. Following
|
||||
the vim philosophy the you have <kbd>i|</kbd> & <kbd>a|</kbd> for the
|
||||
inner and around (including the immidiate right table separator) the
|
||||
table cell.
|
||||
|
||||
- **Delete Row** :
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
" Author: Dhruva Sagar <http://dhruvasagar.com/>
|
||||
" License: MIT (http://www.opensource.org/licenses/MIT)
|
||||
" Website: https://github.com/dhruvasagar/vim-table-mode
|
||||
" Version: 4.0.0
|
||||
" Version: 4.1.0
|
||||
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
|
||||
" (https://gist.github.com/tpope/287147) plugin by Tim Pope.
|
||||
"
|
||||
@@ -49,7 +49,7 @@ function! s:ToggleMapping() "{{{2
|
||||
execute "inoremap <silent> <buffer> " . b:table_mode_separator_map . ' ' .
|
||||
\ b:table_mode_separator_map . "<Esc>:call tablemode#TableizeInsertMode()<CR>a"
|
||||
else
|
||||
execute "iunmap <silent> <buffer> " . b:table_mode_separator_map
|
||||
silent! execute "iunmap <silent> <buffer> " . b:table_mode_separator_map
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
" Author: Dhruva Sagar <http://dhruvasagar.com/>
|
||||
" License: MIT (http://www.opensource.org/licenses/MIT)
|
||||
" Website: https://github.com/dhruvasagar/vim-table-mode
|
||||
" Version: 4.0.0
|
||||
" Version: 4.1.0
|
||||
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
|
||||
" (https://gist.github.com/tpope/287147) plugin by Tim Pope.
|
||||
"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
" Author: Dhruva Sagar <http://dhruvasagar.com/>
|
||||
" License: MIT (http://www.opensource.org/licenses/MIT)
|
||||
" Website: https://github.com/dhruvasagar/vim-table-mode
|
||||
" Version: 4.0.0
|
||||
" Version: 4.1.0
|
||||
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
|
||||
" (https://gist.github.com/tpope/287147) plugin by Tim Pope.
|
||||
"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
" Author: Dhruva Sagar <http://dhruvasagar.com/>
|
||||
" License: MIT (http://www.opensource.org/licenses/MIT)
|
||||
" Website: https://github.com/dhruvasagar/vim-table-mode
|
||||
" Version: 4.0.0
|
||||
" Version: 4.1.0
|
||||
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
|
||||
" (https://gist.github.com/tpope/287147) plugin by Tim Pope.
|
||||
"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
" Author: Dhruva Sagar <http://dhruvasagar.com/>
|
||||
" License: MIT (http://www.opensource.org/licenses/MIT)
|
||||
" Website: https://github.com/dhruvasagar/vim-table-mode
|
||||
" Version: 4.0.0
|
||||
" Version: 4.1.0
|
||||
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
|
||||
" (https://gist.github.com/tpope/287147) plugin by Tim Pope.
|
||||
"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
*table-mode.txt* Table Mode for easy table formatting. v4.0.0
|
||||
*table-mode.txt* Table Mode for easy table formatting. v4.1.0
|
||||
===============================================================================
|
||||
Table Mode, THE AWESOME AUTOMATIC TABLE CREATOR & FORMATTER
|
||||
VERSION 4.0.0
|
||||
VERSION 4.1.0
|
||||
|
||||
Author: Dhruva Sagar <http://dhruvasagar.com/>
|
||||
License: MIT <http://opensource.org/licenses/MIT/>
|
||||
|
||||
@@ -46,7 +46,7 @@ call s:SetGlobalOptDefault('table_mode_corner_corner', '|')
|
||||
|
||||
function! s:TableEchoCell() "{{{1
|
||||
if tablemode#table#IsATableRow('.')
|
||||
echomsg '$' . tablemode#table#RowNr('.') . ',' . tablemode#table#ColumnNr('.')
|
||||
echomsg '$' . tablemode#spreadsheet#RowNr('.') . ',' . tablemode#spreadsheet#ColumnNr('.')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@@ -68,10 +68,10 @@ else
|
||||
endif
|
||||
" }}}2
|
||||
|
||||
command! -nargs=? -range Tableize <line1>,<line2>call tablemode#TableizeRange(<q-args>)
|
||||
command! TableAddFormula call tablemode#table#AddFormula()
|
||||
command! TableModeRealign call tablemode#table#TableRealign('.')
|
||||
command! TableEvalFormulaLine call tablemode#table#EvaluateFormulaLine()
|
||||
command! -nargs=? -range Tableize <line1>,<line2>call tablemode#table#TableizeRange(<q-args>)
|
||||
command! TableAddFormula call tablemode#spreadsheet#AddFormula()
|
||||
command! TableModeRealign call tablemode#spreadsheet#TableRealign('.')
|
||||
command! TableEvalFormulaLine call tablemode#spreadsheet#EvaluateFormulaLine()
|
||||
|
||||
nnoremap <silent> <Plug>(table-mode-tableize) :Tableize<CR>
|
||||
xnoremap <silent> <Plug>(table-mode-tableize) :Tableize<CR>
|
||||
@@ -84,14 +84,14 @@ nnoremap <silent> <Plug>(table-mode-motion-down) :<C-U>call tablemode#table#Tabl
|
||||
nnoremap <silent> <Plug>(table-mode-motion-left) :<C-U>call tablemode#table#TableMotion('h')<CR>
|
||||
nnoremap <silent> <Plug>(table-mode-motion-right) :<C-U>call tablemode#table#TableMotion('l')<CR>
|
||||
|
||||
onoremap <silent> <Plug>(table-mode-cell-text-object-a) :<C-U>call tablemode#table#CellTextObject(0)<CR>
|
||||
onoremap <silent> <Plug>(table-mode-cell-text-object-i) :<C-U>call tablemode#table#CellTextObject(1)<CR>
|
||||
onoremap <silent> <Plug>(table-mode-cell-text-object-a) :<C-U>call tablemode#spreadsheet#CellTextObject(0)<CR>
|
||||
onoremap <silent> <Plug>(table-mode-cell-text-object-i) :<C-U>call tablemode#spreadsheet#CellTextObject(1)<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(table-mode-delete-row) :call tablemode#table#DeleteRow()<CR>
|
||||
nnoremap <silent> <Plug>(table-mode-delete-column) :call tablemode#table#DeleteColumn()<CR>
|
||||
nnoremap <silent> <Plug>(table-mode-delete-row) :call tablemode#spreadsheet#DeleteRow()<CR>
|
||||
nnoremap <silent> <Plug>(table-mode-delete-column) :call tablemode#spreadsheet#DeleteColumn()<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(table-mode-add-formula) :call tablemode#table#AddFormula()<CR>
|
||||
nnoremap <silent> <Plug>(table-mode-eval-formula) :call tablemode#table#EvaluateFormulaLine()<CR>
|
||||
nnoremap <silent> <Plug>(table-mode-add-formula) :call tablemode#spreadsheet#AddFormula()<CR>
|
||||
nnoremap <silent> <Plug>(table-mode-eval-formula) :call tablemode#spreadsheet#EvaluateFormulaLine()<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(table-mode-echo-cell) :call <SID>TableEchoCell()<CR>
|
||||
|
||||
|
||||
@@ -5,14 +5,10 @@ call vspec#hint({'scope': 'tablemode#align#scope()', 'sid': 'tablemode#align#sid
|
||||
|
||||
describe 'Align'
|
||||
it 'should align table content correctly'
|
||||
let lines = ['| This | is a | table |', '| This | is also | a table |']
|
||||
let result = ['| This | is a | table |', '| This | is also | a table |']
|
||||
Expect tablemode#align#Align(lines) == result
|
||||
Expect tablemode#align#Align(readfile('t/fixtures/align/simple_before.txt')) == readfile('t/fixtures/align/simple_after.txt')
|
||||
end
|
||||
|
||||
it 'should align table content with unicode characters correctly'
|
||||
let lines = ['| This | is 測試 | table |', '| This | is also | a table |']
|
||||
let result = ['| This | is 測試 | table |', '| This | is also | a table |']
|
||||
Expect tablemode#align#Align(lines) == result
|
||||
Expect tablemode#align#Align(readfile('t/fixtures/align/unicode_before.txt')) == readfile('t/fixtures/align/unicode_after.txt')
|
||||
end
|
||||
end
|
||||
|
||||
2
t/fixtures/align/simple_after.txt
Normal file
2
t/fixtures/align/simple_after.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
| This | is a | table |
|
||||
| This | is also | a table |
|
||||
2
t/fixtures/align/simple_before.txt
Normal file
2
t/fixtures/align/simple_before.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
|This|is a|table|
|
||||
|This|is also|a table|
|
||||
2
t/fixtures/align/unicode_after.txt
Normal file
2
t/fixtures/align/unicode_after.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
| This | is 測試 | table |
|
||||
| This | is also | a table |
|
||||
2
t/fixtures/align/unicode_before.txt
Normal file
2
t/fixtures/align/unicode_before.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
| This | is 測試 | table |
|
||||
| This | is also | a table |
|
||||
4
t/fixtures/sample.txt
Normal file
4
t/fixtures/sample.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
| test11 | test12 |
|
||||
| test21 | test22 |
|
||||
|
||||
4
t/fixtures/tableize.txt
Normal file
4
t/fixtures/tableize.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
asd,asd;asd,asd
|
||||
asd,asd;asd,asd
|
||||
|
||||
@@ -7,9 +7,7 @@ describe 'spreadsheet'
|
||||
describe 'API'
|
||||
before
|
||||
new
|
||||
normal! ggdG
|
||||
call tablemode#TableModeEnable()
|
||||
normal i
|
||||
read t/fixtures/sample.txt
|
||||
end
|
||||
|
||||
it 'should return the row count'
|
||||
@@ -79,7 +77,6 @@ describe 'spreadsheet'
|
||||
describe 'Manipulations'
|
||||
before
|
||||
new
|
||||
before
|
||||
normal i|test11|test12|
|
||||
|test21|test22|
|
||||
call cursor(1, 3)
|
||||
|
||||
@@ -7,9 +7,7 @@ describe 'table'
|
||||
describe 'API'
|
||||
before
|
||||
new
|
||||
normal! ggdG
|
||||
call tablemode#TableModeEnable()
|
||||
normal i
|
||||
read t/fixtures/sample.txt
|
||||
end
|
||||
|
||||
it 'should return true when inside a table'
|
||||
@@ -24,8 +22,7 @@ describe 'table'
|
||||
describe 'Tableize'
|
||||
before
|
||||
new
|
||||
before
|
||||
new
|
||||
read t/fixtures/tableize.txt
|
||||
end
|
||||
|
||||
it 'should tableize with default delimiter'
|
||||
|
||||
Reference in New Issue
Block a user