mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-09 03:23:47 -05:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87a713efb7 | ||
|
|
272bef4ce0 | ||
|
|
7c4039e5e1 | ||
|
|
28b13a32ab | ||
|
|
599a39c28d | ||
|
|
241d0ccba0 | ||
|
|
ef3e5323d0 | ||
|
|
8489ca0c3b | ||
|
|
a5e2584347 | ||
|
|
c6609fd67d | ||
|
|
f189754d2e | ||
|
|
87f9e9d3f5 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
tags
|
||||||
48
CHANGELOG.md
Normal file
48
CHANGELOG.md
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# Change Log
|
||||||
|
## Version 2.4.0
|
||||||
|
* Added Table Cell text object.
|
||||||
|
* Added api to delete entire table row.
|
||||||
|
* Added api to delete entire table column.
|
||||||
|
|
||||||
|
## Version 2.3.0
|
||||||
|
* Refactored realignment logic. Generating borders by hand.
|
||||||
|
|
||||||
|
## Version 2.2.2
|
||||||
|
* Added mapping for realigning table columns.
|
||||||
|
* Added table motions to move around in the table.
|
||||||
|
|
||||||
|
## Version 2.2.1
|
||||||
|
* Added feature to allow Table-Mode to work within comments. Uses
|
||||||
|
'commentstring' option of vim to identify comments, so it should work for
|
||||||
|
most filetypes as long as 'commentstring' option has been set. This is
|
||||||
|
usually done appropriately in filetype plugins.
|
||||||
|
|
||||||
|
## Version 2.2
|
||||||
|
* Improved :Tableize to now accept a {pattern} just like :Tabular to match the
|
||||||
|
delimiter.
|
||||||
|
|
||||||
|
## Version 2.1.3 :
|
||||||
|
* Bug Fix #1, added new option `g:table_mode_no_border_padding` which removes
|
||||||
|
padding from the border.
|
||||||
|
|
||||||
|
## Version 2.1.2 :
|
||||||
|
* Bug Fixes #2, #3 & #4
|
||||||
|
|
||||||
|
## Version 2.1.1 :
|
||||||
|
* Added option `g:table_mode_align` to allow setting Tabular format option for
|
||||||
|
more control on how Tabular aligns text.
|
||||||
|
|
||||||
|
## Version 2.1 :
|
||||||
|
* VIM loads plugins in alphabetical order and so table-mode would be loaded
|
||||||
|
before Tabularize which it depends on. Hence Moved plugin into an after
|
||||||
|
plugin. Checking if Tabularize is available and finish immidiately if it's
|
||||||
|
not.
|
||||||
|
|
||||||
|
## Version 2.0 :
|
||||||
|
* Moved bulk of code to autoload for vimscript optimisation.
|
||||||
|
|
||||||
|
## Version 1.1 :
|
||||||
|
* Added Tableize command and mapping to convert existing content into a table.
|
||||||
|
|
||||||
|
## Version 1.0 :
|
||||||
|
* First stable release, create tables as you type.
|
||||||
32
README.md
32
README.md
@@ -4,31 +4,9 @@ An awesome automatic table creator & formatter allowing one to create neat
|
|||||||
tables as you type.
|
tables as you type.
|
||||||
|
|
||||||
## Change Log
|
## Change Log
|
||||||
### Version 2.1.3 :
|
See <a
|
||||||
* Bug Fix #1, added new option `g:table_mode_no_border_padding` which removes
|
href="https://github.com/dhruvasagar/vim-table-mode/blob/master/CHANGELOG.md">
|
||||||
padding from the border.
|
CHANGELOG.md </a>
|
||||||
|
|
||||||
### Version 2.1.2 :
|
|
||||||
* Bug Fixes #2, #3 & #4
|
|
||||||
|
|
||||||
### Version 2.1.1 :
|
|
||||||
* Added option g:table_mode_align to allow setting Tabular format option for
|
|
||||||
more control on how Tabular aligns text.
|
|
||||||
|
|
||||||
### Version 2.1 :
|
|
||||||
* VIM loads plugins in alphabetical order and so table-mode would be loaded
|
|
||||||
before Tabularize which it depends on. Hence Moved plugin into an after
|
|
||||||
plugin. Checking if Tabularize is available and finish immidiately if it's
|
|
||||||
not.
|
|
||||||
|
|
||||||
### Version 2.0 :
|
|
||||||
* Moved bulk of code to autoload for vimscript optimisation.
|
|
||||||
|
|
||||||
### Version 1.1 :
|
|
||||||
* Added Tableize command and mapping to convert existing content into a table.
|
|
||||||
|
|
||||||
### Version 1.0 :
|
|
||||||
* First stable release, create tables as you type.
|
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
### Installation
|
### Installation
|
||||||
@@ -80,6 +58,10 @@ sure Tabular is installed and loaded into your runtime to ensure this works.
|
|||||||
`:line1,line2Tableize`, but this is not that intuitive. You can also use
|
`:line1,line2Tableize`, but this is not that intuitive. You can also use
|
||||||
the mapping `<Leader>T` with a `[count]` to apply it to the next `[count]`
|
the mapping `<Leader>T` with a `[count]` to apply it to the next `[count]`
|
||||||
lines in usual vim style.
|
lines in usual vim style.
|
||||||
|
- Move between cells :
|
||||||
|
|
||||||
|
Now you can move between cells using table mode motions. Check `:h
|
||||||
|
table-mode-motion-prefix` for more details.
|
||||||
|
|
||||||
### Demo
|
### Demo
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
" Author: Dhruva Sagar <http://dhruvasagar.com/>
|
" Author: Dhruva Sagar <http://dhruvasagar.com/>
|
||||||
" License: MIT (http://www.opensource.org/licenses/MIT)
|
" License: MIT (http://www.opensource.org/licenses/MIT)
|
||||||
" Website: http://github.com/dhruvasagar/vim-table-mode
|
" Website: http://github.com/dhruvasagar/vim-table-mode
|
||||||
" Version: 2.1.3
|
" Version: 2.4.0
|
||||||
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
|
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
|
||||||
" (https://gist.github.com/tpope/287147) plugin by Tim Pope and
|
" (https://gist.github.com/tpope/287147) plugin by Tim Pope and
|
||||||
" uses a small amount of code from it.
|
" uses a small amount of code from it.
|
||||||
@@ -33,6 +33,11 @@ if !exists(':Tabularize')
|
|||||||
endif
|
endif
|
||||||
" }}}1
|
" }}}1
|
||||||
|
|
||||||
|
" Avoiding side effects {{{1
|
||||||
|
let s:save_cpo = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
" }}}1
|
||||||
|
|
||||||
function! s:SetGlobalOptDefault(opt, val) "{{{1
|
function! s:SetGlobalOptDefault(opt, val) "{{{1
|
||||||
if !exists('g:' . a:opt)
|
if !exists('g:' . a:opt)
|
||||||
let g:{a:opt} = a:val
|
let g:{a:opt} = a:val
|
||||||
@@ -48,13 +53,26 @@ call s:SetGlobalOptDefault('table_mode_fillchar', '-')
|
|||||||
call s:SetGlobalOptDefault('table_mode_toggle_map', '<LocalLeader>tm')
|
call s:SetGlobalOptDefault('table_mode_toggle_map', '<LocalLeader>tm')
|
||||||
call s:SetGlobalOptDefault('table_mode_always_active', 0)
|
call s:SetGlobalOptDefault('table_mode_always_active', 0)
|
||||||
call s:SetGlobalOptDefault('table_mode_delimiter', ',')
|
call s:SetGlobalOptDefault('table_mode_delimiter', ',')
|
||||||
call s:SetGlobalOptDefault('table_mode_tableize_map', '<Leader>T')
|
call s:SetGlobalOptDefault('table_mode_tableize_map', '<Leader>tt')
|
||||||
|
call s:SetGlobalOptDefault('table_mode_tableize_op_map', '<Leader>T')
|
||||||
call s:SetGlobalOptDefault('table_mode_align', 'l1')
|
call s:SetGlobalOptDefault('table_mode_align', 'l1')
|
||||||
call s:SetGlobalOptDefault('table_mode_no_border_padding', '0')
|
call s:SetGlobalOptDefault('table_mode_realign_map', '<Leader>tr')
|
||||||
|
call s:SetGlobalOptDefault('table_mode_motion_prefix', '<Leader>t')
|
||||||
|
call s:SetGlobalOptDefault('table_mode_cell_text_object', 'tc')
|
||||||
|
call s:SetGlobalOptDefault('table_mode_delete_row_map', '<Leader>tdd')
|
||||||
|
call s:SetGlobalOptDefault('table_mode_delete_column_map', '<Leader>tdc')
|
||||||
"}}}1
|
"}}}1
|
||||||
|
|
||||||
|
function! s:TableMotion() "{{{1
|
||||||
|
let direction = nr2char(getchar())
|
||||||
|
for i in range(v:count1)
|
||||||
|
call tablemode#TableMotion(direction)
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
" }}}1
|
||||||
|
|
||||||
" Define Commands & Mappings {{{1
|
" Define Commands & Mappings {{{1
|
||||||
if !g:table_mode_always_active
|
if !g:table_mode_always_active "{{{2
|
||||||
exec "nnoremap <silent> " . g:table_mode_toggle_map .
|
exec "nnoremap <silent> " . g:table_mode_toggle_map .
|
||||||
\ " <Esc>:call tablemode#TableModeToggle()<CR>"
|
\ " <Esc>:call tablemode#TableModeToggle()<CR>"
|
||||||
command! -nargs=0 TableModeToggle call tablemode#TableModeToggle()
|
command! -nargs=0 TableModeToggle call tablemode#TableModeToggle()
|
||||||
@@ -69,11 +87,26 @@ else
|
|||||||
\ table_mode_separator_map . "<Esc>:call tablemode#TableizeInsertMode()<CR>a"
|
\ table_mode_separator_map . "<Esc>:call tablemode#TableizeInsertMode()<CR>a"
|
||||||
unlet table_mode_separator_map
|
unlet table_mode_separator_map
|
||||||
endif
|
endif
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
command! -nargs=? -range Tableize <line1>,<line2>call tablemode#TableizeRange(<q-args>)
|
||||||
|
|
||||||
command! -nargs=0 -range Tableize <line1>,<line2>call tablemode#TableizeRange()
|
|
||||||
execute "xnoremap <silent> " . g:table_mode_tableize_map . " :Tableize<CR>"
|
execute "xnoremap <silent> " . g:table_mode_tableize_map . " :Tableize<CR>"
|
||||||
execute "nnoremap <silent> " . g:table_mode_tableize_map . " :Tableize<CR>"
|
execute "nnoremap <silent> " . g:table_mode_tableize_map . " :Tableize<CR>"
|
||||||
|
execute "xnoremap <silent> " . g:table_mode_tableize_op_map . " :<C-U>call tablemode#TableizeByDelimiter()<CR>"
|
||||||
|
|
||||||
|
execute "nnoremap <silent> " . g:table_mode_realign_map . " :<C-U>call tablemode#TableRealign('.')<CR>"
|
||||||
|
execute "nnoremap <silent> " . g:table_mode_motion_prefix . " :<C-U>call <SID>TableMotion()<CR>"
|
||||||
|
|
||||||
|
execute "onoremap <silent> " . g:table_mode_cell_text_object . " :<C-U>call tablemode#CellTextObject()<CR>"
|
||||||
|
|
||||||
|
execute "nnoremap <silent> " . g:table_mode_delete_row_map . " :<C-U>call tablemode#DeleteRow()<CR>"
|
||||||
|
execute "nnoremap <silent> " . g:table_mode_delete_column_map . " :<C-U>call tablemode#DeleteColumn()<CR>"
|
||||||
"}}}1
|
"}}}1
|
||||||
|
|
||||||
|
" Avoiding side effects {{{1
|
||||||
|
let &cpo = s:save_cpo
|
||||||
|
" }}}1
|
||||||
|
|
||||||
" ModeLine {{{
|
" ModeLine {{{
|
||||||
" vim:fdl=0 fdm=marker
|
" vim:fdl=0 fdm=marker
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
" Author: Dhruva Sagar <http://dhruvasagar.com/>
|
" Author: Dhruva Sagar <http://dhruvasagar.com/>
|
||||||
" License: MIT (http://www.opensource.org/licenses/MIT)
|
" License: MIT (http://www.opensource.org/licenses/MIT)
|
||||||
" Website: http://github.com/dhruvasagar/vim-table-mode
|
" Website: http://github.com/dhruvasagar/vim-table-mode
|
||||||
" Version: 2.1.3
|
" Version: 2.4.0
|
||||||
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
|
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
|
||||||
" (https://gist.github.com/tpope/287147) plugin by Tim Pope and
|
" (https://gist.github.com/tpope/287147) plugin by Tim Pope and
|
||||||
" uses a small amount of code from it.
|
" uses a small amount of code from it.
|
||||||
@@ -35,8 +35,33 @@ function! s:Strlen(text)
|
|||||||
endfunction
|
endfunction
|
||||||
" }}}2
|
" }}}2
|
||||||
|
|
||||||
function! s:CountSeparator(line, separator) "{{{2
|
function! s:GetCommentStart() "{{{2
|
||||||
return s:Strlen(substitute(getline(a:line), '[^' . a:separator . ']', '', 'g'))
|
let cstring = &commentstring
|
||||||
|
if s:Strlen(cstring) > 0
|
||||||
|
return substitute(split(substitute(cstring, '%s', ' ', 'g'))[0], '.', '\\\0', 'g')
|
||||||
|
else
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! s:StartExpr() "{{{2
|
||||||
|
let cstart = s:GetCommentStart()
|
||||||
|
if s:Strlen(cstart) > 0
|
||||||
|
return '^\s*\(' . cstart . '\)\?\s*'
|
||||||
|
else
|
||||||
|
return '^\s*'
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! s:StartCommentExpr() "{{{2
|
||||||
|
let cstartexpr = s:GetCommentStart()
|
||||||
|
if s:Strlen(cstartexpr) > 0
|
||||||
|
return '^\s*' . cstartexpr . '\s*'
|
||||||
|
else
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
" }}}2
|
" }}}2
|
||||||
|
|
||||||
@@ -68,58 +93,136 @@ function! s:SetActive(bool) "{{{2
|
|||||||
endfunction
|
endfunction
|
||||||
" }}}2
|
" }}}2
|
||||||
|
|
||||||
function! s:UpdateLineBorder(line) "{{{2
|
function! s:Line(line) "{{{2
|
||||||
let cline = a:line
|
if type(a:line) == type('')
|
||||||
let hf = '^\s*' . g:table_mode_corner . '[' . g:table_mode_corner . ' ' .
|
return line(a:line)
|
||||||
\ g:table_mode_fillchar . ']*' . g:table_mode_corner . '\?\s*$'
|
else
|
||||||
let curr_line_count = s:CountSeparator(cline, g:table_mode_separator)
|
return a:line
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
if getline(cline-1) =~# hf
|
function! s:GenerateBorder(line) "{{{2
|
||||||
let prev_line_count = s:CountSeparator(cline-1, g:table_mode_corner)
|
let line = s:Line(a:line)
|
||||||
if curr_line_count > prev_line_count
|
|
||||||
silent! execute 'normal! kA' . repeat(g:table_mode_corner, curr_line_count - prev_line_count) . "\<Esc>j"
|
let border = substitute(getline(line)[stridx(getline(line), g:table_mode_separator):-1], g:table_mode_separator, g:table_mode_corner, 'g')
|
||||||
|
let border = substitute(border, '[^' . g:table_mode_corner . ']', g:table_mode_fillchar, 'g')
|
||||||
|
|
||||||
|
let cstartexpr = s:StartCommentExpr()
|
||||||
|
if s:Strlen(cstartexpr) > 0 && getline(line) =~# cstartexpr
|
||||||
|
let indent = matchstr(getline(line), s:StartCommentExpr())
|
||||||
|
return indent . border
|
||||||
|
elseif getline(line) =~# s:StartExpr()
|
||||||
|
let indent = matchstr(getline(line), s:StartExpr())
|
||||||
|
return indent . border
|
||||||
|
else
|
||||||
|
return border
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! s:UpdateLineBorder(line) "{{{2
|
||||||
|
let line = s:Line(a:line)
|
||||||
|
|
||||||
|
let hf = s:StartExpr() . g:table_mode_corner . '[' . g:table_mode_corner .
|
||||||
|
\ g:table_mode_fillchar . ']*' . g:table_mode_corner . '\?\s*$'
|
||||||
|
|
||||||
|
let border = s:GenerateBorder(line)
|
||||||
|
|
||||||
|
let [prev_line, next_line] = [getline(line-1), getline(line+1)]
|
||||||
|
if next_line =~# hf
|
||||||
|
if s:Strlen(border) > s:Strlen(s:GenerateBorder(line + s:RowGap())) || !tablemode#IsATableRow(line + s:RowGap())
|
||||||
|
call setline(line+1, border)
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
call append(cline-1, repeat(g:table_mode_corner, curr_line_count))
|
call append(line, border)
|
||||||
let cline = a:line + 1 " because of the append, the current line moved down
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if getline(cline+1) =~# hf
|
if prev_line =~# hf
|
||||||
let next_line_count = s:CountSeparator(cline+1, g:table_mode_corner)
|
if s:Strlen(border) > s:Strlen(s:GenerateBorder(line - s:RowGap())) || !tablemode#IsATableRow(line - s:RowGap())
|
||||||
if curr_line_count > next_line_count
|
call setline(line-1, border)
|
||||||
silent! execute 'normal! jA' . repeat(g:table_mode_corner, curr_line_count - next_line_count) . "\<Esc>k"
|
endif
|
||||||
end
|
|
||||||
else
|
else
|
||||||
call append(cline, repeat(g:table_mode_corner, curr_line_count))
|
call append(line-1, border)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
" }}}2
|
" }}}2
|
||||||
|
|
||||||
function! s:FillTableBorder() "{{{2
|
function! s:ConvertDelimiterToSeparator(line, ...) "{{{2
|
||||||
let [ current_col, current_line ] = [ col('.'), line('.') ]
|
let delim = g:table_mode_delimiter
|
||||||
if g:table_mode_no_border_padding
|
if a:0 | let delim = a:1 | endif
|
||||||
silent! execute '%s/' . g:table_mode_corner . '\zs\([' .
|
if delim ==# ','
|
||||||
\ g:table_mode_fillchar . ' ]*\)\ze' . g:table_mode_corner .
|
silent! execute a:line . 's/' . "[\'\"][^\'\"]*\\zs,\\ze[^\'\"]*[\'\"]/__COMMA__/g"
|
||||||
\ '/\=repeat("' . g:table_mode_fillchar . '", s:Strlen(submatch(0)))/g'
|
endif
|
||||||
else
|
silent! execute a:line . 's/' . s:StartExpr() . '\zs\ze.\|' . delim . '\|$/' .
|
||||||
silent! execute '%s/' . g:table_mode_corner . ' \zs\([' .
|
\ g:table_mode_separator . '/g'
|
||||||
\ g:table_mode_fillchar . ' ]*\)\ze ' . g:table_mode_corner .
|
if delim ==# ','
|
||||||
\ '/\=repeat("' . g:table_mode_fillchar . '", s:Strlen(submatch(0)))/g'
|
silent! execute a:line . 's/' . "[\'\"][^\'\"]*\\zs__COMMA__\\ze[^\'\"]*[\'\"]/,/g"
|
||||||
endif
|
endif
|
||||||
call cursor(current_line, current_col)
|
|
||||||
endfunction
|
endfunction
|
||||||
" }}}2
|
" }}}2
|
||||||
|
|
||||||
function! s:ConvertDelimiterToSeparator(line) "{{{2
|
function! s:Tableizeline(line, ...) "{{{2
|
||||||
silent! execute a:line . 's/^\s*\zs\ze.\|' . g:table_mode_delimiter .
|
let delim = g:table_mode_delimiter
|
||||||
\ '\|$/' . g:table_mode_separator . '/g'
|
if a:0 && type(a:1) == type('') && !empty(a:1) | let delim = a:1[1:-1] | endif
|
||||||
endfunction
|
call s:ConvertDelimiterToSeparator(a:line, delim)
|
||||||
" }}}2
|
|
||||||
|
|
||||||
function! s:Tableizeline(line) "{{{2
|
|
||||||
call s:ConvertDelimiterToSeparator(a:line)
|
|
||||||
if g:table_mode_border | call s:UpdateLineBorder(a:line) | endif
|
if g:table_mode_border | call s:UpdateLineBorder(a:line) | endif
|
||||||
execute 'Tabularize/[' . g:table_mode_separator . g:table_mode_corner . ']/' . g:table_mode_align
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! s:IsFirstCell() "{{{2
|
||||||
|
return tablemode#ColumnNr('.') ==# 1
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! s:IsLastCell() "{{{2
|
||||||
|
return tablemode#ColumnNr('.') ==# tablemode#ColumnCount('.')
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! s:MoveToFirstRow() "{{{2
|
||||||
|
if tablemode#IsATableRow('.')
|
||||||
|
let line = s:Line('.')
|
||||||
|
while line > 0
|
||||||
|
if !tablemode#IsATableRow(line)
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let line = line - s:RowGap()
|
||||||
|
endwhile
|
||||||
|
call cursor(line + s:RowGap(), col('.'))
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! s:MoveToLastRow() "{{{2
|
||||||
|
if tablemode#IsATableRow('.')
|
||||||
|
let line = s:Line('.')
|
||||||
|
while line <= line('$')
|
||||||
|
if !tablemode#IsATableRow(line)
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let line = line + s:RowGap()
|
||||||
|
endwhile
|
||||||
|
call cursor(line - s:RowGap(), col('.'))
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! s:MoveToStartOfCell() "{{{2
|
||||||
|
if getline('.')[col('.')-1] ==# g:table_mode_separator && !s:IsLastCell()
|
||||||
|
normal! 2l
|
||||||
|
else
|
||||||
|
execute 'normal! F' . g:table_mode_separator . '2l'
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! s:RowGap() "{{{2
|
||||||
|
if g:table_mode_border
|
||||||
|
return 2
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
" }}}2
|
" }}}2
|
||||||
|
|
||||||
@@ -128,13 +231,10 @@ endfunction
|
|||||||
" Public API {{{1
|
" Public API {{{1
|
||||||
|
|
||||||
function! tablemode#TableizeInsertMode() "{{{2
|
function! tablemode#TableizeInsertMode() "{{{2
|
||||||
if s:IsTableModeActive() && getline('.') =~# ('^\s*' . g:table_mode_separator)
|
if s:IsTableModeActive() && getline('.') =~# (s:StartExpr() . g:table_mode_separator)
|
||||||
let column = s:Strlen(substitute(getline('.')[0:col('.')], '[^' . g:table_mode_separator . ']', '', 'g'))
|
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.*'))
|
let position = s:Strlen(matchstr(getline('.')[0:col('.')], '.*' . g:table_mode_separator . '\s*\zs.*'))
|
||||||
if g:table_mode_border | call s:UpdateLineBorder(line('.')) | endif
|
call tablemode#TableRealign('.')
|
||||||
if g:table_mode_no_border_padding && g:table_mode_align !=# 'c0' | let g:table_mode_align = 'c0' | endif
|
|
||||||
execute 'Tabularize/[' . g:table_mode_separator . g:table_mode_corner . ']/' . g:table_mode_align
|
|
||||||
if g:table_mode_border | call s:FillTableBorder() | endif
|
|
||||||
normal! 0
|
normal! 0
|
||||||
call search(repeat('[^' . g:table_mode_separator . ']*' . g:table_mode_separator, column) . '\s\{-\}' . repeat('.', position), 'ce', line('.'))
|
call search(repeat('[^' . g:table_mode_separator . ']*' . g:table_mode_separator, column) . '\s\{-\}' . repeat('.', position), 'ce', line('.'))
|
||||||
endif
|
endif
|
||||||
@@ -161,24 +261,231 @@ function! tablemode#TableModeToggle() "{{{2
|
|||||||
endfunction
|
endfunction
|
||||||
" }}}2
|
" }}}2
|
||||||
|
|
||||||
function! tablemode#TableizeRange() range "{{{2
|
function! tablemode#TableizeRange(...) range "{{{2
|
||||||
let shift = 1
|
let shift = 1
|
||||||
if g:table_mode_border | let shift = shift + 1 | endif
|
if g:table_mode_border | let shift = shift + 1 | endif
|
||||||
call s:Tableizeline(a:firstline)
|
call s:Tableizeline(a:firstline, a:1)
|
||||||
undojoin
|
undojoin
|
||||||
" The first one causes 2 extra lines for top & bottom border while the
|
" The first one causes 2 extra lines for top & bottom border while the
|
||||||
" following lines cause only 1 for the bottom border.
|
" following lines cause only 1 for the bottom border.
|
||||||
let lnum = a:firstline + shift + (g:table_mode_border > 0)
|
let lnum = a:firstline + shift + (g:table_mode_border > 0)
|
||||||
while lnum < (a:firstline + (a:lastline - a:firstline + 1)*shift)
|
while lnum < (a:firstline + (a:lastline - a:firstline + 1)*shift)
|
||||||
call s:Tableizeline(lnum)
|
call s:Tableizeline(lnum, a:1)
|
||||||
undojoin
|
undojoin
|
||||||
let lnum = lnum + shift
|
let lnum = lnum + shift
|
||||||
endwhile
|
endwhile
|
||||||
if g:table_mode_border | call s:FillTableBorder() | endif
|
|
||||||
|
if g:table_mode_border | call tablemode#TableRealign(lnum - shift) | endif
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! tablemode#TableizeByDelimiter() "{{{2
|
||||||
|
let delim = input('/')
|
||||||
|
if delim =~# "\<Esc>" || delim =~# "\<C-C>" | return | endif
|
||||||
|
let vm = visualmode()
|
||||||
|
if vm ==? 'line' || vm ==? 'V'
|
||||||
|
exec line("'<") . ',' . line("'>") . "call tablemode#TableizeRange('/' . delim)"
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! tablemode#TableRealign(line) "{{{2
|
||||||
|
let line = 0
|
||||||
|
if type(a:line) == type('')
|
||||||
|
let line = line(a:line)
|
||||||
|
else
|
||||||
|
let line = a:line
|
||||||
|
endif
|
||||||
|
|
||||||
|
let [lnums, lines] = [[], []]
|
||||||
|
let tline = line
|
||||||
|
while tline > 0
|
||||||
|
if tablemode#IsATableRow(tline)
|
||||||
|
call insert(lnums, tline)
|
||||||
|
call insert(lines, getline(tline))
|
||||||
|
else
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let tline = tline - s:RowGap()
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
let tline = line + s:RowGap()
|
||||||
|
while tline <= line('$')
|
||||||
|
if tablemode#IsATableRow(tline)
|
||||||
|
call add(lnums, tline)
|
||||||
|
call add(lines, getline(tline))
|
||||||
|
else
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let tline = tline + s:RowGap()
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
call tabular#TabularizeStrings(lines, g:table_mode_separator)
|
||||||
|
|
||||||
|
for lnum in lnums
|
||||||
|
let index = index(lnums, lnum)
|
||||||
|
call setline(lnum, lines[index])
|
||||||
|
undojoin
|
||||||
|
call s:UpdateLineBorder(lnum)
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! tablemode#IsATableRow(line) "{{{2
|
||||||
|
return getline(a:line) =~# (s:StartExpr() . g:table_mode_separator)
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! tablemode#RowCount(line) "{{{2
|
||||||
|
let line = s:Line(a:line)
|
||||||
|
|
||||||
|
let [tline, totalRowCount] = [line, 0]
|
||||||
|
while tline > 0
|
||||||
|
if tablemode#IsATableRow(tline)
|
||||||
|
let totalRowCount = totalRowCount + 1
|
||||||
|
else
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let tline = tline - s:RowGap()
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
let tline = line + s:RowGap()
|
||||||
|
while tline <= line('$')
|
||||||
|
if tablemode#IsATableRow(tline)
|
||||||
|
let totalRowCount = totalRowCount + 1
|
||||||
|
else
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let tline = tline + s:RowGap()
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
return totalRowCount
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! tablemode#RowNr(line) "{{{2
|
||||||
|
let line = s:Line(a:line)
|
||||||
|
|
||||||
|
let rowNr = 0
|
||||||
|
while line > 0
|
||||||
|
if tablemode#IsATableRow(line)
|
||||||
|
let rowNr = rowNr + 1
|
||||||
|
else
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let line = line - s:RowGap()
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
return rowNr
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! tablemode#ColumnCount(line) "{{{2
|
||||||
|
let line = s:Line(a:line)
|
||||||
|
|
||||||
|
return s:Strlen(substitute(getline(line), '[^' . g:table_mode_separator . ']', '', 'g'))-1
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! tablemode#ColumnNr(pos) "{{{2
|
||||||
|
let pos = []
|
||||||
|
if type(a:pos) == type('')
|
||||||
|
let pos = [line(a:pos), col(a:pos)]
|
||||||
|
elseif type(a:pos) == type([])
|
||||||
|
let pos = a:pos
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
return s:Strlen(substitute(getline(pos[0])[0:pos[1]-2], '[^' . g:table_mode_separator . ']', '', 'g'))
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! tablemode#TableMotion(direction) "{{{2
|
||||||
|
if tablemode#IsATableRow('.')
|
||||||
|
if a:direction ==# 'l'
|
||||||
|
if s:IsLastCell()
|
||||||
|
if !tablemode#IsATableRow(line('.') + s:RowGap()) | return | endif
|
||||||
|
call tablemode#TableMotion('j')
|
||||||
|
normal! 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
" If line starts with g:table_mode_separator
|
||||||
|
if getline('.')[col('.')-1] ==# g:table_mode_separator
|
||||||
|
normal! 2l
|
||||||
|
else
|
||||||
|
execute 'normal! f' . g:table_mode_separator . '2l'
|
||||||
|
endif
|
||||||
|
elseif a:direction ==# 'h'
|
||||||
|
if s:IsFirstCell()
|
||||||
|
if !tablemode#IsATableRow(line('.') - s:RowGap()) | return | endif
|
||||||
|
call tablemode#TableMotion('k')
|
||||||
|
normal! $
|
||||||
|
endif
|
||||||
|
|
||||||
|
" If line ends with g:table_mode_separator
|
||||||
|
if getline('.')[col('.')-1] ==# g:table_mode_separator
|
||||||
|
execute 'normal! F' . g:table_mode_separator . '2l'
|
||||||
|
else
|
||||||
|
execute 'normal! 2F' . g:table_mode_separator . '2l'
|
||||||
|
endif
|
||||||
|
elseif a:direction ==# 'j'
|
||||||
|
if tablemode#IsATableRow(line('.') + s:RowGap()) | execute 'normal ' . s:RowGap() . 'j' | endif
|
||||||
|
elseif a:direction ==# 'k'
|
||||||
|
if tablemode#IsATableRow(line('.') - s:RowGap()) | execute 'normal ' . s:RowGap() . 'k' | endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! tablemode#CellTextObject() "{{{2
|
||||||
|
if tablemode#IsATableRow('.')
|
||||||
|
call s:MoveToStartOfCell()
|
||||||
|
|
||||||
|
if v:operator ==# 'y'
|
||||||
|
normal! v
|
||||||
|
call search('[^' . g:table_mode_separator . ']\ze\s*' . g:table_mode_separator)
|
||||||
|
else
|
||||||
|
execute 'normal! vf' . g:table_mode_separator
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! tablemode#DeleteColumn() "{{{2
|
||||||
|
if tablemode#IsATableRow('.')
|
||||||
|
for i in range(v:count1)
|
||||||
|
call s:MoveToFirstRow()
|
||||||
|
call s:MoveToStartOfCell()
|
||||||
|
silent! execute "normal! h\<C-V>f" . g:table_mode_separator
|
||||||
|
call s:MoveToLastRow()
|
||||||
|
normal! d
|
||||||
|
endfor
|
||||||
|
|
||||||
|
call tablemode#TableRealign('.')
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! tablemode#DeleteRow() "{{{2
|
||||||
|
if tablemode#IsATableRow('.')
|
||||||
|
for i in range(v:count1)
|
||||||
|
if tablemode#RowCount('.') ==# 1
|
||||||
|
normal! kVjjd
|
||||||
|
else
|
||||||
|
normal! kVjd
|
||||||
|
endif
|
||||||
|
|
||||||
|
if tablemode#IsATableRow(line('.')+1)
|
||||||
|
normal! j
|
||||||
|
else
|
||||||
|
normal! k
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
call tablemode#TableRealign('.')
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
" }}}2
|
" }}}2
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
|
|
||||||
" ModeLine {{{
|
|
||||||
" vim:fdm=marker
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
*table-mode.txt* Table Mode for easy table formatting. v2.1.2
|
*table-mode.txt* Table Mode for easy table formatting. v2.4.0
|
||||||
===============================================================================
|
===============================================================================
|
||||||
Table Mode, THE AWESOME AUTOMATIC TABLE CREATOR & FORMATTER
|
Table Mode, THE AWESOME AUTOMATIC TABLE CREATOR & FORMATTER
|
||||||
VERSION 2.1.2
|
VERSION 2.4.0
|
||||||
|
|
||||||
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/>
|
||||||
@@ -34,93 +34,188 @@ make sure it is installed and loaded.
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
GETTING STARTED *table-mode-getting-started*
|
GETTING STARTED *table-mode-getting-started*
|
||||||
|
|
||||||
Using Table Mode is dead simple. You simply start typing on a new line with
|
Create Table on the fly:
|
||||||
the table separator - |g:table-mode-separator|, and you just type away! The
|
Using Table Mode is dead simple. You simply start typing on a new line
|
||||||
plugin does the rest automatically for you as you type. With each additional
|
with the table separator - |g:table-mode-separator|, and you just type
|
||||||
separator you add, it aligns the table properly, without having to do
|
away! The plugin does the rest automatically for you as you type. With
|
||||||
anything else.
|
each additional separator you add, it aligns the table properly,
|
||||||
|
without having to do anything else.
|
||||||
|
|
||||||
The table mode is disabled by default and you can enter table mode using
|
The table mode is disabled by default and you can enter table mode
|
||||||
|table-mode-toggle-map| or you can also enable it permanently using
|
using |table-mode-toggle-map| or you can also enable it permanently
|
||||||
|g:table-mode-always-active| if you wish.
|
using |g:table-mode-always-active| if you wish.
|
||||||
|
|
||||||
|
Table Mode allows for creation of tables within comments, it looks at
|
||||||
|
the 'commentstring' setting to identify whether the current line is
|
||||||
|
commented.
|
||||||
|
|
||||||
|
Tableize content:
|
||||||
|
Table Mode enables conversion of delimited text into tables. Again
|
||||||
|
like table creation, this is also applicable within comments.
|
||||||
|
|
||||||
|
Manipulation of tables:
|
||||||
|
Tableize provides 3 easy ways to quickly manipulate tables.
|
||||||
|
|
||||||
|
1. Cell Text Object : A text object for table cell
|
||||||
|
defined by |table-mode-cell-text-object|. You can use it with an
|
||||||
|
operator (d,c,y) to manipulate it easily. If you delete the cell using
|
||||||
|
this, it will delete the table separator along with it so if you type
|
||||||
|
out some new stuff, you will have to re-add it, which triggers a
|
||||||
|
re-alignment and the table would be formatted again.
|
||||||
|
|
||||||
|
2. Delete Column : Delete an entire table column using
|
||||||
|
|table-mode-delete-column-map| .
|
||||||
|
|
||||||
|
3. Delete Row : Delete an entire table row using
|
||||||
|
|table-mode-delete-row-map|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
OPTIONS *table-mode-options*
|
OPTIONS *table-mode-options*
|
||||||
|
|
||||||
Overview:
|
Overview:
|
||||||
|table-mode-options-loaded| ............. Disable the plugin
|
|table-mode-loaded| ............. Disable the plugin.
|
||||||
|table-mode-options-border| ............. Enable border
|
|table-mode-border| ............. Enable border.
|
||||||
|table-mode-options-corner| ............. Set corner character
|
|table-mode-corner| ............. Set corner character.
|
||||||
|table-mode-options-separator| .......... Set separator character
|
|table-mode-separator| .......... Set separator character.
|
||||||
|table-mode-options-fillchar| ........... Set table fillchar character
|
|table-mode-fillchar| ........... Set table fillchar character.
|
||||||
|table-mode-options-toggle-map| ......... Set table mode toggle mapping
|
|table-mode-toggle-map| ......... Set table mode toggle mapping.
|
||||||
|table-mode-options-always-active| ...... Set table mode to always enabled
|
|table-mode-always-active| ...... Set table mode to always enabled.
|
||||||
|table-mode-options-delimiter| .......... Set the delimiter for Tableize
|
|table-mode-delimiter| .......... Set the delimiter for Tableize.
|
||||||
|table-mode-options-align| .............. Set the text alignment for
|
|table-mode-tableize-map| ....... Set mapping for Tableize.
|
||||||
Tableize
|
|table-mode-tableize-op-map| .... Set mapping for Tableize with input.
|
||||||
|table-mode-options-no-border-padding| .. Set for no border padding.
|
|table-mode-align| .............. Set the text alignment for
|
||||||
|
Tableize.
|
||||||
|
|table-mode-no-border-padding| .. Set for no border padding.
|
||||||
|
|table-mode-realign-map| ........ Set mapping for table realigning.
|
||||||
|
|table-mode-motion-prefix| ...... Set prefix for table mode motions.
|
||||||
|
|table-mode-cell-text-object| ... Set mapping for table cell object.
|
||||||
|
|table-mode-delete-row-map| ..... Set mapping for deleting table row.
|
||||||
|
|table-mode-delete-column-map| .. Set mapping for deleting table
|
||||||
|
column.
|
||||||
|
|
||||||
g:table_mode_loaded *table-mode-options-loaded*
|
g:table_mode_loaded *table-mode-loaded*
|
||||||
Use this option to disable the plugin: >
|
Use this option to disable the plugin: >
|
||||||
let g:table_mode_loaded = 1
|
let g:table_mode_loaded = 1
|
||||||
<
|
<
|
||||||
|
|
||||||
g:table_mode_border *table-mode-options-border*
|
g:table_mode_border *table-mode-border*
|
||||||
Use this option to enable / disable table border: >
|
Use this option to enable / disable table border: >
|
||||||
let g:table_mode_border = 1
|
let g:table_mode_border = 1
|
||||||
<
|
<
|
||||||
|
|
||||||
g:table_mode_corner *table-mode-options-corner*
|
g:table_mode_corner *table-mode-corner*
|
||||||
Use this option to define the table corner character: >
|
Use this option to define the table corner character: >
|
||||||
let g:table_mode_corner = '+'
|
let g:table_mode_corner = '+'
|
||||||
<
|
<
|
||||||
g:table_mode_separator *table-mode-options-separator*
|
g:table_mode_separator *table-mode-separator*
|
||||||
Use this option to define the table column separator character: >
|
Use this option to define the table column separator character: >
|
||||||
let g:table_mode_separator = '|'
|
let g:table_mode_separator = '|'
|
||||||
<
|
<
|
||||||
This option also defines the trigger to be used to start creating a
|
This option also defines the trigger to be used to start creating a
|
||||||
table row in insert mode.
|
table row in insert mode.
|
||||||
|
|
||||||
g:table_mode_fillchar *table-mode-options-fillchar*
|
g:table_mode_fillchar *table-mode-fillchar*
|
||||||
Use this option to define the table border fill character: >
|
Use this option to define the table border fill character: >
|
||||||
let g:table_mode_fillchar = '-'
|
let g:table_mode_fillchar = '-'
|
||||||
<
|
<
|
||||||
|
|
||||||
g:table_mode_toggle_map *table-mode-options-toggle-map*
|
g:table_mode_toggle_map *table-mode-toggle-map*
|
||||||
Use this option to define the mapping for toggling the table mode: >
|
Use this option to define the mapping for toggling the table mode: >
|
||||||
let g:table_mode_toggle_map = '<Leader>tm'
|
let g:table_mode_toggle_map = '<Leader>tm'
|
||||||
<
|
<
|
||||||
Read |table-mode-mappings-toggle| for more info.
|
Read |table-mode-mappings-toggle| for more info.
|
||||||
|
|
||||||
g:table_mode_always_active *table-mode-options-always-active*
|
g:table_mode_always_active *table-mode-always-active*
|
||||||
Use this option to permanently enable the table mode: >
|
Use this option to permanently enable the table mode: >
|
||||||
let g:table_mode_always_active = 0
|
let g:table_mode_always_active = 0
|
||||||
<
|
<
|
||||||
This will trigger table creation once you type the
|
This will trigger table creation once you type the
|
||||||
|table-mode-options-separator| as long as it's the first character on
|
|table-mode-separator| as long as it's the first character on
|
||||||
the line, which can be annoying. I recommend you to instead use the
|
the line, which can be annoying. I recommend you to instead use the
|
||||||
|table-mode-mappings-toggle| or |table-mode-commands-toggle| to toggle
|
|table-mode-mappings-toggle| or |table-mode-commands-toggle| to toggle
|
||||||
the table mode or |table-mode-commands-enable| to enable and
|
the table mode or |table-mode-commands-enable| to enable and
|
||||||
|table-mode-commands-disable| to disable mode when needed.
|
|table-mode-commands-disable| to disable mode when needed.
|
||||||
|
|
||||||
g:table_mode_delimiter *table-mode-options-delimiter*
|
g:table_mode_delimiter *table-mode-delimiter*
|
||||||
Use this option to define the delimiter which used by
|
Use this option to define the delimiter which used by
|
||||||
|table-mode-commands-tableize|
|
|table-mode-commands-tableize| >
|
||||||
|
let g:table_mode_delimiter = ','
|
||||||
|
<
|
||||||
|
|
||||||
g:table_mode_align *table-mode-options-align*
|
g:table_mode_tableize_map *table-mode-tableize-map*
|
||||||
|
Use this option to define the mapping to invoke |:Tableize| with
|
||||||
|
default delimiter, i.e. |:Tableize| without input. >
|
||||||
|
let g:table_mode_tableize_map = '<Leader>tt'
|
||||||
|
<
|
||||||
|
|
||||||
|
g:table_mode_tableize_op_map *table-mode-tableize-op-map*
|
||||||
|
Use this option to define the mapping to invoke |:Tableize| with input
|
||||||
|
parameter. This option will ask for command-line input {pattern} that
|
||||||
|
defines the delimiter. >
|
||||||
|
let g:table_mode_tableize_op_map = '<Leader>T'
|
||||||
|
<
|
||||||
|
|
||||||
|
g:table_mode_align *table-mode-align*
|
||||||
Use this option to define the format for text alignment to be used for
|
Use this option to define the format for text alignment to be used for
|
||||||
the tables. Go through |tabular-walkthrough| for details on how to set
|
the tables. Go through |tabular-walkthrough| for details on how to set
|
||||||
the format options for alignment. >
|
the format options for alignment. >
|
||||||
let g:table_mode_align = 'l1'
|
let g:table_mode_align = 'l1'
|
||||||
<
|
<
|
||||||
|
|
||||||
g:table_mode_no_border_padding *table-mode-options-no-border-padding*
|
g:table_mode_no_border_padding *table-mode-no-border-padding*
|
||||||
Use this option to remove the border padding (extra spaces around the
|
Use this option to remove the border padding (extra spaces around the
|
||||||
|table-mode-options-fillchar|). >
|
|table-mode-fillchar|). >
|
||||||
let g:table_mode_no_border_padding = 0
|
let g:table_mode_no_border_padding = 0
|
||||||
<
|
<
|
||||||
NOTE this option changes |table-mode-options-align| to 'c0', so that
|
NOTE this option changes |table-mode-align| to 'c0', so that
|
||||||
there is no extra padding around the contents.
|
there is no extra padding around the contents.
|
||||||
|
|
||||||
|
g:table_mode_realign_map *table-mode-realign-map*
|
||||||
|
Use this option to define the mapping for realigning table columns.
|
||||||
|
This is useful in case you make edits to an existing table. >
|
||||||
|
let g:table_mode_realign_map = '<Leader>tr'
|
||||||
|
<
|
||||||
|
|
||||||
|
g:table_mode_motion_prefix *table-mode-motion-prefix*
|
||||||
|
Use this option to define the prefix for table mode motion commands. >
|
||||||
|
let g:table_mode_motion_prefix = '<Leader>t'
|
||||||
|
<
|
||||||
|
You can move to the next / previous row / column using the motion
|
||||||
|
commands. The motions 'hjkl' follow the prefix are in accordance to
|
||||||
|
standard vim character motions to make them easier to remember. They
|
||||||
|
may also be preceeded with a [count]. The 'h', 'l' (left and right
|
||||||
|
motions) wrap around the table row and move to the previous rows last
|
||||||
|
column, next rows first column respectively if one exists.
|
||||||
|
|
||||||
|
g:table_mode_cell_text_object *table-mode-cell-text-object*
|
||||||
|
Use this option to define the table mode cell text object. >
|
||||||
|
let g:table_mode_cell_text_object = 'tc'
|
||||||
|
<
|
||||||
|
This text object automatically selects different text depending on the
|
||||||
|
context.
|
||||||
|
|
||||||
|
If you delete the cell using either the 'd' or the 'c'
|
||||||
|
operator, it will delete cell contents along with the table separator.
|
||||||
|
In case you do it with 'c' while you add new content for the cell, you
|
||||||
|
will have to re-add the |table-mode-separator|, which will trigger the
|
||||||
|
re-alignment of the table again and format it correctly.
|
||||||
|
|
||||||
|
If you simply want to yank the table content, this text object will
|
||||||
|
select only the table cell contents, without the padding (extra space
|
||||||
|
around the text) or the |table-mode-separator|.
|
||||||
|
|
||||||
|
g:table_mode_delete_row_map *table-mode-delete-row-map*
|
||||||
|
Use this option to define the mapping for deletion of the entire table
|
||||||
|
row. You can delete multiple rows by preceeding this with a [count]. >
|
||||||
|
let g:table_mode_delete_column_map = '<Leader>tdd'
|
||||||
|
|
||||||
|
g:table_mode_delete_column_map *table-mode-delete-column-map*
|
||||||
|
USe this option to define the mapping for deletion of the entire table
|
||||||
|
column. You can delete multiple columns to the right by preceeding
|
||||||
|
this with a [count] >
|
||||||
|
let g:table_mode_delete_column_map = '<Leader>tdc'
|
||||||
|
<
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
MAPPINGS *table-mode-mappings*
|
MAPPINGS *table-mode-mappings*
|
||||||
|
|
||||||
@@ -129,52 +224,82 @@ MAPPINGS *table-mode-mappings*
|
|||||||
using the |toggle-mode-options-toggle-map| option.
|
using the |toggle-mode-options-toggle-map| option.
|
||||||
|
|
||||||
NOTE This is applicable only if
|
NOTE This is applicable only if
|
||||||
|table-mode-options-always-active| is not set.
|
|table-mode-always-active| is not set.
|
||||||
|
|
||||||
*table-mode-mappings-trigger*
|
*table-mode-mappings-trigger*
|
||||||
| Trigger table creation in table mode. You can change this
|
| Trigger table creation in table mode. You can change this
|
||||||
using the |toggle-mode-options-separator| option.
|
using the |toggle-mode-options-separator| option.
|
||||||
|
|
||||||
<Leader>T Triggers |table-mode-commands-tableize| on the visually
|
<Leader>tt Triggers |table-mode-commands-tableize| on the visually
|
||||||
selected content.
|
selected content.
|
||||||
|
|
||||||
|
*table-mode-mappings-op-trigger*
|
||||||
|
<Leader>T Triggers |table-mode-commands-tableize| on the visually
|
||||||
|
selected asking for user to input the delimiter.
|
||||||
|
|
||||||
|
*table-mode-mappings-realign*
|
||||||
|
<Leader>tr Realigns table columns
|
||||||
|
|
||||||
|
*table-mode-mappings-motions*
|
||||||
|
<Leader>t[hjkl] Move to previous | below | above | right cell in the table.
|
||||||
|
|
||||||
|
*table-mode-mappings-delete-row*
|
||||||
|
<Leader>tdd Delete the entire table row you are on or multiple rows using
|
||||||
|
a [count]. You can change this using |table-mode-delete-row-map|
|
||||||
|
option.
|
||||||
|
|
||||||
|
*table-mode-mappings-delete-column*
|
||||||
|
<Leader>tdc Delete entire table column you are within. You can preceed it
|
||||||
|
with a [count] to delete multiple columns to the right. You
|
||||||
|
can change this using |table-mode-delete-column-map| option.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
COMMANDS *table-mode-commands*
|
COMMANDS *table-mode-commands*
|
||||||
|
|
||||||
*:TableModeToggle*
|
*:TableModeToggle*
|
||||||
*table-mode-commands-toggle*
|
*table-mode-:TableModeToggle*
|
||||||
:TableModeToggle
|
:TableModeToggle
|
||||||
Toggles the table mode. Same effect as |toggle-mode-mappings-toggle|.
|
Toggles the table mode. Same effect as |toggle-mode-mappings-toggle|.
|
||||||
|
|
||||||
NOTE this is applicable only if |table-mode-options-always-active| is
|
NOTE this is applicable only if |table-mode-always-active| is
|
||||||
not set.
|
not set.
|
||||||
|
|
||||||
*:TableModeEnable*
|
*:TableModeEnable*
|
||||||
*table-mode-commands-enable*
|
*table-mode-:TableModeEnable*
|
||||||
:TableModeEnable
|
:TableModeEnable
|
||||||
Enables Table Mode.
|
Enables Table Mode.
|
||||||
|
|
||||||
NOTE this is applicable only if |table-mode-options-always-active| is
|
NOTE this is applicable only if |table-mode-always-active| is
|
||||||
not set.
|
not set.
|
||||||
|
|
||||||
*:TableModeDisable*
|
*:TableModeDisable*
|
||||||
*table-mode-commands-disable*
|
*table-mode-:TableModeDisable*
|
||||||
:TableModeDisable
|
:TableModeDisable
|
||||||
Disables Table Mode.
|
Disables Table Mode.
|
||||||
|
|
||||||
NOTE this is applicable only if |table-mode-options-always-active| is
|
NOTE this is applicable only if |table-mode-always-active| is
|
||||||
not set.
|
not set.
|
||||||
|
|
||||||
*:Tableize*
|
*:Tableize*
|
||||||
:Tableize *table-mode-commands-tableize*
|
*table-mode-:Tableize*
|
||||||
|
:Tableize
|
||||||
This converts the current line into a table if it consists of
|
This converts the current line into a table if it consists of
|
||||||
|table-mode-options-delimiter|. This accepts a range, without which it
|
|table-mode-delimiter|. This accepts a range, without which it
|
||||||
applies on the current line.
|
applies on the current line.
|
||||||
|
|
||||||
|
This accepts a {pattern} similar to Tabular which defines the
|
||||||
|
delimiter. eg.) >
|
||||||
|
:Tableize/;
|
||||||
|
<
|
||||||
|
The above command will Tableize using ';' as the delimiter.
|
||||||
|
|
||||||
|
NOTE this is optional, by default without the expression it will
|
||||||
|
tableize the content using |g:table-mode-delimiter| as the delimiter.
|
||||||
===============================================================================
|
===============================================================================
|
||||||
CONTRIBUTING *table-mode-contributing*
|
CONTRIBUTING *table-mode-contributing*
|
||||||
|
|
||||||
If you want to take a stab at it, by all means, send me a pull request on
|
If you want to take a stab at it, by all means, send me a pull request on
|
||||||
Github (http://github.com/dhruvasagar/table-mode.git) or get in touch with me
|
Github (http://github.com/dhruvasagar/table-mode) or get in touch with me
|
||||||
directly via e-mail at dhruva 'dot' sagar 'at' gmail.com.
|
directly via e-mail at dhruva 'dot' sagar 'at' gmail.com.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
@@ -183,4 +308,4 @@ 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/table-mode/issues.
|
http://github.com/dhruvasagar/table-mode/issues.
|
||||||
|
|
||||||
vim:tw=78:ts=8:ft=help:norl:
|
vim:tw=78:ts=8:ft=help:norl:ai
|
||||||
|
|||||||
29
doc/tags
29
doc/tags
@@ -1,29 +0,0 @@
|
|||||||
:TableModeDisable table-mode.txt /*:TableModeDisable*
|
|
||||||
:TableModeEnable table-mode.txt /*:TableModeEnable*
|
|
||||||
:TableModeToggle table-mode.txt /*:TableModeToggle*
|
|
||||||
:Tableize table-mode.txt /*:Tableize*
|
|
||||||
table-mode-commands table-mode.txt /*table-mode-commands*
|
|
||||||
table-mode-commands-disable table-mode.txt /*table-mode-commands-disable*
|
|
||||||
table-mode-commands-enable table-mode.txt /*table-mode-commands-enable*
|
|
||||||
table-mode-commands-tableize table-mode.txt /*table-mode-commands-tableize*
|
|
||||||
table-mode-commands-toggle table-mode.txt /*table-mode-commands-toggle*
|
|
||||||
table-mode-contents table-mode.txt /*table-mode-contents*
|
|
||||||
table-mode-contributing table-mode.txt /*table-mode-contributing*
|
|
||||||
table-mode-getting-started table-mode.txt /*table-mode-getting-started*
|
|
||||||
table-mode-introduction table-mode.txt /*table-mode-introduction*
|
|
||||||
table-mode-mappings table-mode.txt /*table-mode-mappings*
|
|
||||||
table-mode-mappings-toggle table-mode.txt /*table-mode-mappings-toggle*
|
|
||||||
table-mode-mappings-trigger table-mode.txt /*table-mode-mappings-trigger*
|
|
||||||
table-mode-options table-mode.txt /*table-mode-options*
|
|
||||||
table-mode-options-align table-mode.txt /*table-mode-options-align*
|
|
||||||
table-mode-options-always-active table-mode.txt /*table-mode-options-always-active*
|
|
||||||
table-mode-options-border table-mode.txt /*table-mode-options-border*
|
|
||||||
table-mode-options-corner table-mode.txt /*table-mode-options-corner*
|
|
||||||
table-mode-options-delimiter table-mode.txt /*table-mode-options-delimiter*
|
|
||||||
table-mode-options-fillchar table-mode.txt /*table-mode-options-fillchar*
|
|
||||||
table-mode-options-loaded table-mode.txt /*table-mode-options-loaded*
|
|
||||||
table-mode-options-separator table-mode.txt /*table-mode-options-separator*
|
|
||||||
table-mode-options-toggle-map table-mode.txt /*table-mode-options-toggle-map*
|
|
||||||
table-mode-report-issues table-mode.txt /*table-mode-report-issues*
|
|
||||||
table-mode-requirements table-mode.txt /*table-mode-requirements*
|
|
||||||
table-mode.txt table-mode.txt /*table-mode.txt*
|
|
||||||
Reference in New Issue
Block a user