diff --git a/README.md b/README.md index b964cfc..742321f 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,25 @@ $ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-m To start using the plugin in the on-the-fly mode use `:TableModeToggle` mapped to \tm by default (which means \\ t m if you didn't override the by `:let mapleader = ","` to have , t m). +> Tip : +> You can use the following to quickly enable / disable table mode in insert +> mode by using `||` or `__` : +> ```vim +> inoreabbrev +> \ isAtStartOfLine('\|\|') ? +> \ ':TableModeEnable' : '' +> inoreabbrev __ +> \ isAtStartOfLine('__') ? +> \ ':silent! TableModeDisable' : '__' +> +> fun! isAtStartOfLine(mapping) +> let text_before_cursor = getline('.')[0 : col('.')-1] +> let mapping_pattern = '\V' . escape(a:mapping, '\') +> let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\') +> return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$') +> endf +> ``` + Enter the first line, delimiting columns by the `|` symbol. The plugin reacts by inserting spaces between the text and the separator if you omit them: | name | address | phone |