diff --git a/README.md b/README.md index d83a7a7..fd112e7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# VIM Table Mode v4.6.4.4 [![Build Status](https://travis-ci.org/dhruvasagar/vim-table-mode.png?branch=master)](https://travis-ci.org/dhruvasagar/vim-table-mode) +# VIM Table Mode v4.6.5 [![Build Status](https://travis-ci.org/dhruvasagar/vim-table-mode.png?branch=master)](https://travis-ci.org/dhruvasagar/vim-table-mode) An awesome automatic table creator & formatter allowing one to create neat tables as you type. diff --git a/autoload/tablemode.vim b/autoload/tablemode.vim index 4e035fc..b03e142 100644 --- a/autoload/tablemode.vim +++ b/autoload/tablemode.vim @@ -91,10 +91,25 @@ function! s:ToggleSyntax() "{{{2 endif endfunction +function! s:ToggleAutoAlign() "{{{2 + if !g:table_mode_auto_align | return | endif + + if tablemode#IsActive() + augroup TableModeAutoAlign + au! + + autocmd CursorHold,CursorHoldI * nested silent! call tablemode#table#Realign('.') + augroup END + else + silent! augroup! TableModeAutoAlign + endif +endfunction + function! s:SetActive(bool) "{{{2 let b:table_mode_active = a:bool call s:ToggleSyntax() call s:ToggleMapping() + call s:ToggleAutoAlign() if tablemode#IsActive() doautocmd User TableModeEnabled else diff --git a/doc/table-mode.txt b/doc/table-mode.txt index 6892568..3dda5de 100644 --- a/doc/table-mode.txt +++ b/doc/table-mode.txt @@ -1,7 +1,7 @@ *table-mode.txt* Table Mode for easy table formatting =============================================================================== Table Mode, THE AWESOME AUTOMATIC TABLE CREATOR & FORMATTER - VERSION 4.6.4.4 + VERSION 4.6.5 Author: Dhruva Sagar License: MIT @@ -170,6 +170,8 @@ Overview: |table-mode-echo-cell-map| ...... Set the echo cell mapping |table-mode-sort-map| ........... Set the table sort mapping |table-mode-syntax| ............. Control table mode syntax + |table-mode-auto-align| ......... Set if the table mode should auto + align as you type g:loaded_table_mode *table-mode-loaded* Use this option to disable the plugin: > @@ -302,6 +304,11 @@ g:table_mode_syntax *table-mode-syntax* not. > let g:table_mode_syntax = 1 < +g:table_mode_auto_align *table-mode-auto-align* + Set if the table mode should auto align as you type when table mode is + active. > + let g:table_mode_auto_align = 1 +< =============================================================================== MAPPINGS *table-mode-mappings* diff --git a/plugin/table-mode.vim b/plugin/table-mode.vim index 4fbb20b..1c779a8 100644 --- a/plugin/table-mode.vim +++ b/plugin/table-mode.vim @@ -45,6 +45,7 @@ call s:SetGlobalOptDefault('table_mode_echo_cell_map', 't?') call s:SetGlobalOptDefault('table_mode_sort_map', 'ts') call s:SetGlobalOptDefault('table_mode_syntax', 1) +call s:SetGlobalOptDefault('table_mode_auto_align', 1) function! s:TableEchoCell() "{{{1 if tablemode#table#IsRow('.') diff --git a/t/config/options.vim b/t/config/options.vim index ea1d41b..5b23596 100644 --- a/t/config/options.vim +++ b/t/config/options.vim @@ -27,3 +27,4 @@ let g:table_mode_echo_cell_map = 't?' let g:table_mode_sort_map = 'ts' let g:table_mode_syntax = 1 +let g:table_mode_auto_align = 1