Add option to auto align table while editing #73

This commit is contained in:
Dhruva Sagar
2017-03-09 10:58:51 +05:30
parent d3b70df0a6
commit 1eef73fc5b
5 changed files with 26 additions and 2 deletions

View File

@@ -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 An awesome automatic table creator & formatter allowing one to create neat
tables as you type. tables as you type.

View File

@@ -91,10 +91,25 @@ function! s:ToggleSyntax() "{{{2
endif endif
endfunction 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 function! s:SetActive(bool) "{{{2
let b:table_mode_active = a:bool let b:table_mode_active = a:bool
call s:ToggleSyntax() call s:ToggleSyntax()
call s:ToggleMapping() call s:ToggleMapping()
call s:ToggleAutoAlign()
if tablemode#IsActive() if tablemode#IsActive()
doautocmd User TableModeEnabled doautocmd User TableModeEnabled
else else

View File

@@ -1,7 +1,7 @@
*table-mode.txt* Table Mode for easy table formatting *table-mode.txt* Table Mode for easy table formatting
=============================================================================== ===============================================================================
Table Mode, THE AWESOME AUTOMATIC TABLE CREATOR & FORMATTER Table Mode, THE AWESOME AUTOMATIC TABLE CREATOR & FORMATTER
VERSION 4.6.4.4 VERSION 4.6.5
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/>
@@ -170,6 +170,8 @@ Overview:
|table-mode-echo-cell-map| ...... Set the echo cell mapping |table-mode-echo-cell-map| ...... Set the echo cell mapping
|table-mode-sort-map| ........... Set the table sort mapping |table-mode-sort-map| ........... Set the table sort mapping
|table-mode-syntax| ............. Control table mode syntax |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* g:loaded_table_mode *table-mode-loaded*
Use this option to disable the plugin: > Use this option to disable the plugin: >
@@ -302,6 +304,11 @@ g:table_mode_syntax *table-mode-syntax*
not. > not. >
let g:table_mode_syntax = 1 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* MAPPINGS *table-mode-mappings*

View File

@@ -45,6 +45,7 @@ call s:SetGlobalOptDefault('table_mode_echo_cell_map', '<Leader>t?')
call s:SetGlobalOptDefault('table_mode_sort_map', '<Leader>ts') call s:SetGlobalOptDefault('table_mode_sort_map', '<Leader>ts')
call s:SetGlobalOptDefault('table_mode_syntax', 1) call s:SetGlobalOptDefault('table_mode_syntax', 1)
call s:SetGlobalOptDefault('table_mode_auto_align', 1)
function! s:TableEchoCell() "{{{1 function! s:TableEchoCell() "{{{1
if tablemode#table#IsRow('.') if tablemode#table#IsRow('.')

View File

@@ -27,3 +27,4 @@ let g:table_mode_echo_cell_map = '<Leader>t?'
let g:table_mode_sort_map = '<Leader>ts' let g:table_mode_sort_map = '<Leader>ts'
let g:table_mode_syntax = 1 let g:table_mode_syntax = 1
let g:table_mode_auto_align = 1