diff --git a/autoload/tablemode.vim b/autoload/tablemode.vim index eb464d8..1486be3 100644 --- a/autoload/tablemode.vim +++ b/autoload/tablemode.vim @@ -4,7 +4,7 @@ " Author: Dhruva Sagar " License: MIT (http://www.opensource.org/licenses/MIT) " Website: http://github.com/dhruvasagar/vim-table-mode -" Version: 3.2 +" Version: 3.3 " 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. @@ -169,13 +169,8 @@ function! s:ToggleMapping() "{{{2 execute "inoremap " . b:table_mode_separator_map . ' ' . \ b:table_mode_separator_map . ":call tablemode#TableizeInsertMode()a" - - execute "inoremap " . g:table_mode_corner . - \ g:table_mode_fillchar . " :call tablemode#AddHeaderBorder('.')A" else execute "iunmap " . b:table_mode_separator_map - - execute "iunmap " . g:table_mode_corner . g:table_mode_fillchar endif endfunction @@ -184,6 +179,14 @@ function! s:SetActive(bool) "{{{2 call s:ToggleMapping() 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 + else + return '' + endif +endfunction + function! s:GenerateHeaderBorder(line) "{{{2 let line = s:Line(a:line) if tablemode#IsATableRow(line - s:RowGap()) || tablemode#IsATableRow(line + s:RowGap()) @@ -194,6 +197,7 @@ function! s:GenerateHeaderBorder(line) "{{{2 if tablemode#IsATableRow(line - s:RowGap()) && s:Strlen(line_val) < s:Strlen(getline(line - s:RowGap())) let line_val = getline(line - s:RowGap()) endif + 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 , '') @@ -209,6 +213,8 @@ function! s:GenerateHeaderBorder(line) "{{{2 else return border endif + else + return s:DefaultHeaderBorder() endif endfunction diff --git a/doc/table-mode.txt b/doc/table-mode.txt index 92d74e6..75d655b 100644 --- a/doc/table-mode.txt +++ b/doc/table-mode.txt @@ -1,7 +1,7 @@ -*table-mode.txt* Table Mode for easy table formatting. v3.2 +*table-mode.txt* Table Mode for easy table formatting. v3.3 =============================================================================== Table Mode, THE AWESOME AUTOMATIC TABLE CREATOR & FORMATTER - VERSION 3.2 + VERSION 3.3 Author: Dhruva Sagar License: MIT @@ -323,11 +323,9 @@ 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 this - will be considered as the table header. You can change this by - changing |table-mode-corner| and |table-mode-fillchar| - options. This is an iabbrev so is triggered when you press - space or after typing the mapping. +|| 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. =============================================================================== COMMANDS *table-mode-commands* diff --git a/plugin/table-mode.vim b/plugin/table-mode.vim index 90cd719..24cbc3d 100644 --- a/plugin/table-mode.vim +++ b/plugin/table-mode.vim @@ -4,7 +4,7 @@ " Author: Dhruva Sagar " License: MIT (http://www.opensource.org/licenses/MIT) " Website: http://github.com/dhruvasagar/vim-table-mode -" Version: 3.2 +" Version: 3.3 " 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.