mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-08 11:03:47 -05:00
Releasing v2.2
- Improved :Tableize to accept a {patter} in a similar way as
:Tabularize does. eg.)
:Tableize/;
The above command will tableize the selection taking ';' as the
delimiter rather than the default ',' defined by the
g:table_mode_delimiter option. If you do not provide a pattern, the
default delimiter will be used.
- Updated doc/table-mode.txt
- Updated README.md
- Added tags to .gitignore to avoid checking in tags file.
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tags
|
||||
@@ -4,6 +4,10 @@ An awesome automatic table creator & formatter allowing one to create neat
|
||||
tables as you type.
|
||||
|
||||
## Change Log
|
||||
### 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.
|
||||
|
||||
@@ -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: 2.1.3
|
||||
" Version: 2.2
|
||||
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
|
||||
" (https://gist.github.com/tpope/287147) plugin by Tim Pope and
|
||||
" uses a small amount of code from it.
|
||||
@@ -53,7 +53,8 @@ call s:SetGlobalOptDefault('table_mode_fillchar', '-')
|
||||
call s:SetGlobalOptDefault('table_mode_toggle_map', '<LocalLeader>tm')
|
||||
call s:SetGlobalOptDefault('table_mode_always_active', 0)
|
||||
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_no_border_padding', '0')
|
||||
"}}}1
|
||||
@@ -75,9 +76,10 @@ else
|
||||
unlet table_mode_separator_map
|
||||
endif
|
||||
|
||||
command! -nargs=0 -range Tableize <line1>,<line2>call tablemode#TableizeRange()
|
||||
command! -nargs=? -range Tableize <line1>,<line2>call tablemode#TableizeRange(<q-args>)
|
||||
execute "xnoremap <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>"
|
||||
"}}}1
|
||||
|
||||
" Avoiding side effects {{{1
|
||||
|
||||
@@ -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: 2.1.3
|
||||
" Version: 2.2
|
||||
" Note: This plugin was heavily inspired by the 'CucumberTables.vim'
|
||||
" (https://gist.github.com/tpope/287147) plugin by Tim Pope and
|
||||
" uses a small amount of code from it.
|
||||
@@ -110,14 +110,18 @@ function! s:FillTableBorder() "{{{2
|
||||
endfunction
|
||||
" }}}2
|
||||
|
||||
function! s:ConvertDelimiterToSeparator(line) "{{{2
|
||||
silent! execute a:line . 's/^\s*\zs\ze.\|' . g:table_mode_delimiter .
|
||||
\ '\|$/' . g:table_mode_separator . '/g'
|
||||
function! s:ConvertDelimiterToSeparator(line, ...) "{{{2
|
||||
let delim = g:table_mode_delimiter
|
||||
if a:0 | let delim = a:1 | endif
|
||||
silent! execute a:line . 's/^\s*\zs\ze.\|' . delim . '\|$/' .
|
||||
\ g:table_mode_separator . '/g'
|
||||
endfunction
|
||||
" }}}2
|
||||
|
||||
function! s:Tableizeline(line) "{{{2
|
||||
call s:ConvertDelimiterToSeparator(a:line)
|
||||
function! s:Tableizeline(line, ...) "{{{2
|
||||
let delim = g:table_mode_delimiter
|
||||
if a:0 && type(a:1) == type('') && !empty(a:1) | let delim = a:1[1:-1] | endif
|
||||
call s:ConvertDelimiterToSeparator(a:line, delim)
|
||||
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
|
||||
@@ -161,16 +165,16 @@ function! tablemode#TableModeToggle() "{{{2
|
||||
endfunction
|
||||
" }}}2
|
||||
|
||||
function! tablemode#TableizeRange() range "{{{2
|
||||
function! tablemode#TableizeRange(...) range "{{{2
|
||||
let shift = 1
|
||||
if g:table_mode_border | let shift = shift + 1 | endif
|
||||
call s:Tableizeline(a:firstline)
|
||||
call s:Tableizeline(a:firstline, a:1)
|
||||
undojoin
|
||||
" The first one causes 2 extra lines for top & bottom border while the
|
||||
" following lines cause only 1 for the bottom border.
|
||||
let lnum = a:firstline + shift + (g:table_mode_border > 0)
|
||||
while lnum < (a:firstline + (a:lastline - a:firstline + 1)*shift)
|
||||
call s:Tableizeline(lnum)
|
||||
call s:Tableizeline(lnum, a:1)
|
||||
undojoin
|
||||
let lnum = lnum + shift
|
||||
endwhile
|
||||
@@ -178,6 +182,16 @@ function! tablemode#TableizeRange() range "{{{2
|
||||
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
|
||||
|
||||
" }}}1
|
||||
|
||||
" ModeLine {{{
|
||||
|
||||
@@ -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.2
|
||||
===============================================================================
|
||||
Table Mode, THE AWESOME AUTOMATIC TABLE CREATOR & FORMATTER
|
||||
VERSION 2.1.2
|
||||
VERSION 2.2
|
||||
|
||||
Author: Dhruva Sagar <http://dhruvasagar.com/>
|
||||
License: MIT <http://opensource.org/licenses/MIT/>
|
||||
@@ -48,78 +48,95 @@ The table mode is disabled by default and you can enter table mode using
|
||||
OPTIONS *table-mode-options*
|
||||
|
||||
Overview:
|
||||
|table-mode-options-loaded| ............. Disable the plugin
|
||||
|table-mode-options-border| ............. Enable border
|
||||
|table-mode-options-corner| ............. Set corner character
|
||||
|table-mode-options-separator| .......... Set separator character
|
||||
|table-mode-options-fillchar| ........... Set table fillchar character
|
||||
|table-mode-options-toggle-map| ......... Set table mode toggle mapping
|
||||
|table-mode-options-always-active| ...... Set table mode to always enabled
|
||||
|table-mode-options-delimiter| .......... Set the delimiter for Tableize
|
||||
|table-mode-options-align| .............. Set the text alignment for
|
||||
Tableize
|
||||
|table-mode-options-no-border-padding| .. Set for no border padding.
|
||||
|table-mode-loaded| ............. Disable the plugin.
|
||||
|table-mode-border| ............. Enable border.
|
||||
|table-mode-corner| ............. Set corner character.
|
||||
|table-mode-separator| .......... Set separator character.
|
||||
|table-mode-fillchar| ........... Set table fillchar character.
|
||||
|table-mode-toggle-map| ......... Set table mode toggle mapping.
|
||||
|table-mode-always-active| ...... Set table mode to always enabled.
|
||||
|table-mode-delimiter| .......... Set the delimiter for Tableize.
|
||||
|table-mode-tableize-map| ....... Set mapping for Tableize.
|
||||
|table-mode-tableize-op-map| .... Set mapping for Tableize with input.
|
||||
|table-mode-align| .............. Set the text alignment for
|
||||
Tableize.
|
||||
|table-mode-no-border-padding| .. Set for no border padding.
|
||||
|
||||
g:table_mode_loaded *table-mode-options-loaded*
|
||||
g:table_mode_loaded *table-mode-loaded*
|
||||
Use this option to disable the plugin: >
|
||||
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: >
|
||||
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: >
|
||||
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: >
|
||||
let g:table_mode_separator = '|'
|
||||
<
|
||||
This option also defines the trigger to be used to start creating a
|
||||
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: >
|
||||
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: >
|
||||
let g:table_mode_toggle_map = '<Leader>tm'
|
||||
<
|
||||
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: >
|
||||
let g:table_mode_always_active = 0
|
||||
<
|
||||
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
|
||||
|table-mode-mappings-toggle| or |table-mode-commands-toggle| to toggle
|
||||
the table mode or |table-mode-commands-enable| to enable and
|
||||
|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
|
||||
|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
|
||||
the tables. Go through |tabular-walkthrough| for details on how to set
|
||||
the format options for alignment. >
|
||||
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
|
||||
|table-mode-options-fillchar|). >
|
||||
|table-mode-fillchar|). >
|
||||
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.
|
||||
===============================================================================
|
||||
MAPPINGS *table-mode-mappings*
|
||||
@@ -129,15 +146,19 @@ MAPPINGS *table-mode-mappings*
|
||||
using the |toggle-mode-options-toggle-map| option.
|
||||
|
||||
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*
|
||||
| Trigger table creation in table mode. You can change this
|
||||
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.
|
||||
|
||||
*table-mode-mappings-op-trigger*
|
||||
<Leader>T Triggers |table-mode-commands-tableize| on the visually
|
||||
selected asking for user to input the delimiter.
|
||||
|
||||
===============================================================================
|
||||
COMMANDS *table-mode-commands*
|
||||
|
||||
@@ -146,7 +167,7 @@ COMMANDS *table-mode-commands*
|
||||
:TableModeToggle
|
||||
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.
|
||||
|
||||
*:TableModeEnable*
|
||||
@@ -154,7 +175,7 @@ COMMANDS *table-mode-commands*
|
||||
:TableModeEnable
|
||||
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.
|
||||
|
||||
*:TableModeDisable*
|
||||
@@ -162,15 +183,24 @@ COMMANDS *table-mode-commands*
|
||||
:TableModeDisable
|
||||
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.
|
||||
|
||||
*:Tableize*
|
||||
*table-mode-:Tableize*
|
||||
:Tableize
|
||||
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.
|
||||
|
||||
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*
|
||||
|
||||
|
||||
30
doc/tags
30
doc/tags
@@ -1,30 +0,0 @@
|
||||
:TableModeDisable table-mode.txt /*:TableModeDisable*
|
||||
:TableModeEnable table-mode.txt /*:TableModeEnable*
|
||||
:TableModeToggle table-mode.txt /*:TableModeToggle*
|
||||
:Tableize table-mode.txt /*:Tableize*
|
||||
table-mode-:TableModeDisable table-mode.txt /*table-mode-:TableModeDisable*
|
||||
table-mode-:TableModeEnable table-mode.txt /*table-mode-:TableModeEnable*
|
||||
table-mode-:TableModeToggle table-mode.txt /*table-mode-:TableModeToggle*
|
||||
table-mode-:Tableize table-mode.txt /*table-mode-:Tableize*
|
||||
table-mode-commands table-mode.txt /*table-mode-commands*
|
||||
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-no-border-padding table-mode.txt /*table-mode-options-no-border-padding*
|
||||
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