Updated the README

Fixed the tip
This commit is contained in:
Dhruva Sagar
2016-09-21 14:05:56 +05:30
parent 8bacd0ba66
commit 5b3b2f7c05

View File

@@ -34,19 +34,19 @@ To start using the plugin in the on-the-fly mode use `:TableModeToggle` mapped t
> You can use the following to quickly enable / disable table mode in insert
> mode by using `||` or `__` :
> ```vim
> inoreabbrev <expr> <bar><bar>
> \ s:isAtStartOfLine('\|\|') ?
> \ '<c-o>:TableModeEnable<cr><bar><space><bar><left><left>' : '<bar><bar>'
> inoreabbrev <expr> __
> \ s:isAtStartOfLine('__') ?
> \ '<c-o>:silent! TableModeDisable<cr>' : '__'
>
> fun! s:isAtStartOfLine(mapping)
> function! s: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
> endfunction
>
> inoreabbrev <expr> <bar><bar>
> \ <SID>isAtStartOfLine('\|\|') ?
> \ '<c-o>:TableModeEnable<cr><bar><space><bar><left><left>' : '<bar><bar>'
> inoreabbrev <expr> __
> \ <SID>isAtStartOfLine('__') ?
> \ '<c-o>:silent! TableModeDisable<cr>' : '__'
> ```
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: