Merge pull request #35 from p0deje/master

Added option to disable all mappings. Fixes #34
This commit is contained in:
Dhruva Sagar
2014-07-25 07:27:53 +05:30
4 changed files with 39 additions and 32 deletions

View File

@@ -53,35 +53,37 @@ function! s:ToggleMapping() "{{{2
" '|' is a special character, we need to map <Bar> instead " '|' is a special character, we need to map <Bar> instead
if g:table_mode_separator ==# '|' | let separator_map = '<Bar>' | endif if g:table_mode_separator ==# '|' | let separator_map = '<Bar>' | endif
if tablemode#IsActive() if !g:table_mode_disable_mappings
call s:Map('<Plug>(table-mode-tableize)', separator_map, 'i') if tablemode#IsActive()
call s:Map('<Plug>(table-mode-motion-up)', '{<Bar>', 'n') call s:Map('<Plug>(table-mode-tableize)', separator_map, 'i')
call s:Map('<Plug>(table-mode-motion-down)', '}<Bar>', 'n') call s:Map('<Plug>(table-mode-motion-up)', '{<Bar>', 'n')
call s:Map('<Plug>(table-mode-motion-left)', '[<Bar>', 'n') call s:Map('<Plug>(table-mode-motion-down)', '}<Bar>', 'n')
call s:Map('<Plug>(table-mode-motion-right)', ']<Bar>', 'n') call s:Map('<Plug>(table-mode-motion-left)', '[<Bar>', 'n')
call s:Map('<Plug>(table-mode-motion-right)', ']<Bar>', 'n')
call s:Map('<Plug>(table-mode-cell-text-object-a)', 'a<Bar>', 'ox') call s:Map('<Plug>(table-mode-cell-text-object-a)', 'a<Bar>', 'ox')
call s:Map('<Plug>(table-mode-cell-text-object-i)', 'i<Bar>', 'ox') call s:Map('<Plug>(table-mode-cell-text-object-i)', 'i<Bar>', 'ox')
call s:Map('<Plug>(table-mode-realign)', '<Leader>tr', 'n') call s:Map('<Plug>(table-mode-realign)', '<Leader>tr', 'n')
call s:Map('<Plug>(table-mode-delete-row)', '<Leader>tdd', 'n') call s:Map('<Plug>(table-mode-delete-row)', '<Leader>tdd', 'n')
call s:Map('<Plug>(table-mode-delete-column)', '<Leader>tdc', 'n') call s:Map('<Plug>(table-mode-delete-column)', '<Leader>tdc', 'n')
call s:Map('<Plug>(table-mode-add-formula)', '<Leader>tfa', 'n') call s:Map('<Plug>(table-mode-add-formula)', '<Leader>tfa', 'n')
call s:Map('<Plug>(table-mode-eval-formula)', '<Leader>tfe', 'n') call s:Map('<Plug>(table-mode-eval-formula)', '<Leader>tfe', 'n')
call s:Map('<Plug>(table-mode-echo-cell)', '<Leader>t?', 'n') call s:Map('<Plug>(table-mode-echo-cell)', '<Leader>t?', 'n')
else else
call s:UnMap(separator_map, 'i') call s:UnMap(separator_map, 'i')
call s:UnMap('{<Bar>', 'n') call s:UnMap('{<Bar>', 'n')
call s:UnMap('}<Bar>', 'n') call s:UnMap('}<Bar>', 'n')
call s:UnMap('[<Bar>', 'n') call s:UnMap('[<Bar>', 'n')
call s:UnMap(']<Bar>', 'n') call s:UnMap(']<Bar>', 'n')
call s:UnMap('a<Bar>', 'o') call s:UnMap('a<Bar>', 'o')
call s:UnMap('i<Bar>', 'o') call s:UnMap('i<Bar>', 'o')
call s:UnMap('<Leader>tdd', 'n') call s:UnMap('<Leader>tdd', 'n')
call s:UnMap('<Leader>tdc', 'n') call s:UnMap('<Leader>tdc', 'n')
call s:UnMap('<Leader>tfa', 'n') call s:UnMap('<Leader>tfa', 'n')
call s:UnMap('<Leader>tfe', 'n') call s:UnMap('<Leader>tfe', 'n')
call s:UnMap('<Leader>t?', 'n') call s:UnMap('<Leader>t?', 'n')
endif
endif endif
endfunction endfunction

View File

@@ -20,7 +20,7 @@ CONTENTS *table-mode-contents*
INTRODUCTION *table-mode-introduction* INTRODUCTION *table-mode-introduction*
Table Mode is simple plugin that makes building tables in vim a breeze. It is Table Mode is simple plugin that makes building tables in vim a breeze. It is
inspired from tpope's auto aligning script for creating tables in vim - inspired from tpope's auto aligning script for creating tables in vim -
https://gist.github.com/tpope/287147, which in turn utilizes the Tabular https://gist.github.com/tpope/287147, which in turn utilizes the Tabular
Plugin. Plugin.
@@ -57,7 +57,7 @@ Move between cells :
You can use |table-mode-map-prefix| option to define the prefix You can use |table-mode-map-prefix| option to define the prefix
mapping to be used before 'hjkl'. The left | right motions wrap around mapping to be used before 'hjkl'. The left | right motions wrap around
the table and move to the next | previous row after the last | first the table and move to the next | previous row after the last | first
cell in the current row if one exists. cell in the current row if one exists.
Manipulation of tables: Manipulation of tables:
Tableize provides 3 easy ways to quickly manipulate tables. Tableize provides 3 easy ways to quickly manipulate tables.
@@ -213,6 +213,9 @@ g:table_mode_align_char *table-mode-align-char*
alignments for columns in the table header border. > alignments for columns in the table header border. >
let g:table_mode_align_char = ':' let g:table_mode_align_char = ':'
< <
g:table_mode_disable_mappings table-mode-disable-mappings
Set this to true to disable all mappings.
let g:table_mode_disable_mappings = 1
=============================================================================== ===============================================================================
MAPPINGS *table-mode-mappings* MAPPINGS *table-mode-mappings*
@@ -224,7 +227,7 @@ MAPPINGS *table-mode-mappings*
*table-mode-mappings-toggle* *table-mode-mappings-toggle*
<Leader>tm Toggle table mode for the current buffer. You can change this <Leader>tm Toggle table mode for the current buffer. You can change this
using the |toggle-mode-options-toggle-map| option. using the |toggle-mode-options-toggle-map| option.
NOTE This is applicable only if |table-mode-always-active| is NOTE This is applicable only if |table-mode-always-active| is
not set. not set.
@@ -272,7 +275,7 @@ MAPPINGS *table-mode-mappings*
accordingly. This invokes the |TableEvalFormulaLine| command. accordingly. This invokes the |TableEvalFormulaLine| command.
|| Expands to a header border. You can change this by changing || Expands to a header border. You can change this by changing
|table-mode-separator| option. You can change the character to |table-mode-separator| option. You can change the character to
be used for te extreme corners of the border by changing be used for te extreme corners of the border by changing
|table-mode-corner-corner| option. |table-mode-corner-corner| option.
@@ -298,7 +301,7 @@ COMMANDS *table-mode-commands*
*:TableModeDisable* *:TableModeDisable*
*table-mode-:TableModeDisable* *table-mode-:TableModeDisable*
:TableModeDisable :TableModeDisable
Disables Table Mode. Disables Table Mode.
NOTE this is applicable only if |table-mode-always-active| is NOTE this is applicable only if |table-mode-always-active| is
not set. not set.

View File

@@ -43,6 +43,7 @@ call s:SetGlobalOptDefault('table_mode_always_active', 0)
call s:SetGlobalOptDefault('table_mode_delimiter', ',') call s:SetGlobalOptDefault('table_mode_delimiter', ',')
call s:SetGlobalOptDefault('table_mode_corner_corner', '|') call s:SetGlobalOptDefault('table_mode_corner_corner', '|')
call s:SetGlobalOptDefault('table_mode_align_char', ':') call s:SetGlobalOptDefault('table_mode_align_char', ':')
call s:SetGlobalOptDefault('table_mode_disable_mappings', 0)
function! s:TableEchoCell() "{{{1 function! s:TableEchoCell() "{{{1
if tablemode#table#IsRow('.') if tablemode#table#IsRow('.')

View File

@@ -7,3 +7,4 @@ let g:table_mode_always_active = 0
let g:table_mode_delimiter = ',' let g:table_mode_delimiter = ','
let g:table_mode_corner_corner = '|' let g:table_mode_corner_corner = '|'
let g:table_mode_align_char = ':' let g:table_mode_align_char = ':'
let g:table_mode_disable_mappings = 0