mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-08 19:13:46 -05:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8489ca0c3b | ||
|
|
a5e2584347 | ||
|
|
c6609fd67d |
36
CHANGELOG.md
Normal file
36
CHANGELOG.md
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Change Log
|
||||||
|
## 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,35 +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.2
|
See <a
|
||||||
* Improved :Tableize to now accept a {pattern} just like :Tabular to match the
|
href="https://github.com/dhruvasagar/vim-table-mode/blob/master/CHANGELOG.md">
|
||||||
delimiter.
|
CHANGELOG.md </a>
|
||||||
|
|
||||||
### 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.
|
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
### Installation
|
### Installation
|
||||||
|
|||||||
@@ -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.2
|
" Version: 2.2.1
|
||||||
" 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.
|
||||||
|
|||||||
@@ -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.2
|
" Version: 2.2.1
|
||||||
" 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.
|
||||||
@@ -40,6 +40,21 @@ function! s:CountSeparator(line, separator) "{{{2
|
|||||||
endfunction
|
endfunction
|
||||||
" }}}2
|
" }}}2
|
||||||
|
|
||||||
|
function! s:GetCommentStart() "{{{2
|
||||||
|
return split(substitute(&commentstring, '%s', ' ', 'g'))[0]
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! s:StartExpr() "{{{2
|
||||||
|
return '^\s*\(' . s:GetCommentStart() . '\)\?\s*'
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
|
function! s:StartCommentExpr() "{{{2
|
||||||
|
return '^\s*' . s:GetCommentStart() . '\s*'
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
function! s:IsTableModeActive() "{{{2
|
function! s:IsTableModeActive() "{{{2
|
||||||
if g:table_mode_always_active | return 1 | endif
|
if g:table_mode_always_active | return 1 | endif
|
||||||
|
|
||||||
@@ -70,7 +85,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:UpdateLineBorder(line) "{{{2
|
function! s:UpdateLineBorder(line) "{{{2
|
||||||
let cline = a:line
|
let cline = a:line
|
||||||
let hf = '^\s*' . g:table_mode_corner . '[' . g:table_mode_corner . ' ' .
|
let hf = s:StartExpr() . g:table_mode_corner . '[' . g:table_mode_corner . ' ' .
|
||||||
\ g:table_mode_fillchar . ']*' . g:table_mode_corner . '\?\s*$'
|
\ g:table_mode_fillchar . ']*' . g:table_mode_corner . '\?\s*$'
|
||||||
let curr_line_count = s:CountSeparator(cline, g:table_mode_separator)
|
let curr_line_count = s:CountSeparator(cline, g:table_mode_separator)
|
||||||
|
|
||||||
@@ -79,8 +94,13 @@ function! s:UpdateLineBorder(line) "{{{2
|
|||||||
if curr_line_count > prev_line_count
|
if curr_line_count > prev_line_count
|
||||||
silent! execute 'normal! kA' . repeat(g:table_mode_corner, curr_line_count - prev_line_count) . "\<Esc>j"
|
silent! execute 'normal! kA' . repeat(g:table_mode_corner, curr_line_count - prev_line_count) . "\<Esc>j"
|
||||||
endif
|
endif
|
||||||
|
else
|
||||||
|
if getline(cline) =~# s:StartCommentExpr()
|
||||||
|
let indent = matchstr(getline(cline), s:StartCommentExpr())
|
||||||
|
call append(cline-1, indent . repeat(g:table_mode_corner, curr_line_count))
|
||||||
else
|
else
|
||||||
call append(cline-1, repeat(g:table_mode_corner, curr_line_count))
|
call append(cline-1, repeat(g:table_mode_corner, curr_line_count))
|
||||||
|
endif
|
||||||
let cline = a:line + 1 " because of the append, the current line moved down
|
let cline = a:line + 1 " because of the append, the current line moved down
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -89,9 +109,14 @@ function! s:UpdateLineBorder(line) "{{{2
|
|||||||
if curr_line_count > next_line_count
|
if curr_line_count > next_line_count
|
||||||
silent! execute 'normal! jA' . repeat(g:table_mode_corner, curr_line_count - next_line_count) . "\<Esc>k"
|
silent! execute 'normal! jA' . repeat(g:table_mode_corner, curr_line_count - next_line_count) . "\<Esc>k"
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
if getline(cline) =~# s:StartCommentExpr()
|
||||||
|
let indent = matchstr(getline(cline), s:StartCommentExpr())
|
||||||
|
call append(cline, indent . repeat(g:table_mode_corner, curr_line_count))
|
||||||
else
|
else
|
||||||
call append(cline, repeat(g:table_mode_corner, curr_line_count))
|
call append(cline, repeat(g:table_mode_corner, curr_line_count))
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
" }}}2
|
" }}}2
|
||||||
|
|
||||||
@@ -113,7 +138,7 @@ endfunction
|
|||||||
function! s:ConvertDelimiterToSeparator(line, ...) "{{{2
|
function! s:ConvertDelimiterToSeparator(line, ...) "{{{2
|
||||||
let delim = g:table_mode_delimiter
|
let delim = g:table_mode_delimiter
|
||||||
if a:0 | let delim = a:1 | endif
|
if a:0 | let delim = a:1 | endif
|
||||||
silent! execute a:line . 's/^\s*\zs\ze.\|' . delim . '\|$/' .
|
silent! execute a:line . 's/' . s:StartExpr() . '\zs\ze.\|' . delim . '\|$/' .
|
||||||
\ g:table_mode_separator . '/g'
|
\ g:table_mode_separator . '/g'
|
||||||
endfunction
|
endfunction
|
||||||
" }}}2
|
" }}}2
|
||||||
@@ -132,7 +157,7 @@ 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
|
if g:table_mode_border | call s:UpdateLineBorder(line('.')) | endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
*table-mode.txt* Table Mode for easy table formatting. v2.2
|
*table-mode.txt* Table Mode for easy table formatting. v2.2.1
|
||||||
===============================================================================
|
===============================================================================
|
||||||
Table Mode, THE AWESOME AUTOMATIC TABLE CREATOR & FORMATTER
|
Table Mode, THE AWESOME AUTOMATIC TABLE CREATOR & FORMATTER
|
||||||
VERSION 2.2
|
VERSION 2.2.1
|
||||||
|
|
||||||
Author: Dhruva Sagar <http://dhruvasagar.com/>
|
Author: Dhruva Sagar <http://dhruvasagar.com/>
|
||||||
License: MIT <http://opensource.org/licenses/MIT/>
|
License: MIT <http://opensource.org/licenses/MIT/>
|
||||||
|
|||||||
Reference in New Issue
Block a user