Added the iabbrevs to README
This commit is contained in:
Dhruva Sagar
2016-07-11 13:22:12 +05:30
parent 1bf139b30d
commit b420dedbf5

View File

@@ -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 <kbd>\<Leader\>tm</kbd> by default (which means <kbd>\\</kbd> <kbd>t</kbd> <kbd>m</kbd> if you didn't override the <Leader> by `:let mapleader = ","` to have <kbd>,</kbd> <kbd>t</kbd> <kbd>m</kbd>).
> Tip :
> You can use the following to quickly enable / disable table mode in insert
> mode by using `||` or `__` :
> ```vim
> 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>' : '__'
>
> fun! <SID>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 |