diff --git a/autoload/tablemode.vim b/autoload/tablemode.vim index 302d2b9..07ab643 100644 --- a/autoload/tablemode.vim +++ b/autoload/tablemode.vim @@ -22,13 +22,9 @@ function! s:UnMap(map, mode) "{{{2 endfunction function! s:ToggleMapping() "{{{2 - let separator_map = g:table_mode_separator - " '|' is a special character, we need to map instead - if g:table_mode_separator ==# '|' | let separator_map = '' | endif - if !g:table_mode_disable_mappings if tablemode#IsActive() - call s:Map('(table-mode-tableize)', separator_map, 'i') + call s:Map('(table-mode-tableize)', g:table_mode_separator_map, 'i') call s:Map('(table-mode-motion-up)', g:table_mode_motion_up_map, 'n') call s:Map('(table-mode-motion-down)', g:table_mode_motion_down_map, 'n') call s:Map('(table-mode-motion-left)', g:table_mode_motion_left_map, 'n') @@ -47,7 +43,7 @@ function! s:ToggleMapping() "{{{2 call s:Map('(table-mode-echo-cell)', g:table_mode_echo_cell_map, 'n') call s:Map('(table-mode-sort)', g:table_mode_sort_map, 'n') else - call s:UnMap(separator_map, 'i') + call s:UnMap(g:table_mode_separator_map, 'i') call s:UnMap(g:table_mode_motion_up_map, 'n') call s:UnMap(g:table_mode_motion_down_map, 'n') call s:UnMap(g:table_mode_motion_left_map, 'n') @@ -207,7 +203,7 @@ endfunction function! tablemode#TableizeRange(...) range "{{{2 let lnum = a:firstline let total = (a:lastline - a:firstline + 1) - echom total + " echom total let cntr = 1 while cntr <= total call s:Tableizeline(lnum, a:1) diff --git a/plugin/table-mode.vim b/plugin/table-mode.vim index 5a0166e..c55be27 100644 --- a/plugin/table-mode.vim +++ b/plugin/table-mode.vim @@ -18,6 +18,13 @@ endfunction call s:SetGlobalOptDefault('table_mode_corner', '+') call s:SetGlobalOptDefault('table_mode_verbose', 1) call s:SetGlobalOptDefault('table_mode_separator', '|') +" '|' is a special character, we need to map instead +" the character to map from +let g:table_mode_separator_map = get(g:, 'table_mode_separator_map', g:table_mode_separator) +if g:table_mode_separator_map ==# '|' | let g:table_mode_separator_map = '' | endif +" the character to map to (when inserting the separator) +let g:table_mode_separator_map_target = g:table_mode_separator +if g:table_mode_separator_map_target ==# '|' | let g:table_mode_separator_map_target = '' | endif call s:SetGlobalOptDefault('table_mode_escaped_separator_regex', '\V\C\\\@1" g:table_mode_map_prefix . g:table_mode_toggle_map ":call tablemode#Toggle()" command! -nargs=0 TableModeToggle call tablemode#Toggle() command! -nargs=0 TableModeEnable call tablemode#Enable() command! -nargs=0 TableModeDisable call tablemode#Disable() else - let table_mode_separator_map = g:table_mode_separator - " '|' is a special character, we need to map instead - if g:table_mode_separator ==# '|' | let table_mode_separator_map = '' | endif - - execute "inoremap " . table_mode_separator_map . ' ' . - \ table_mode_separator_map . ":call tablemode#TableizeInsertMode()a" - unlet table_mode_separator_map + execute "inoremap " . g:table_mode_separator_map . ' ' . + \ g:table_mode_separator_map_target . ":call tablemode#TableizeInsertMode()a" endif " }}}2 @@ -84,9 +87,7 @@ command! TableAddFormula call tablemode#spreadsheet#formula#Add() command! TableModeRealign call tablemode#table#Realign('.') command! TableEvalFormulaLine call tablemode#spreadsheet#formula#EvaluateFormulaLine() -" '|' is a special character, we need to map instead -if g:table_mode_separator ==# '|' | let separator_map = '' | endif -execute 'inoremap (table-mode-tableize)' separator_map . ':call tablemode#TableizeInsertMode()a' +execute 'inoremap (table-mode-tableize)' g:table_mode_separator_map . ':call tablemode#TableizeInsertMode()a' nnoremap (table-mode-tableize) :Tableize xnoremap (table-mode-tableize) :Tableize