mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-08 11:03:47 -05:00
19
README.md
19
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 <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>).
|
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>
|
||||||
|
> \ 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)
|
||||||
|
> 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:
|
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 |
|
| name | address | phone |
|
||||||
|
|||||||
Reference in New Issue
Block a user