From 0810512c5412bd0b877aee162d70dc07e3fb64cc Mon Sep 17 00:00:00 2001 From: Dhruva Sagar Date: Sat, 18 May 2013 03:55:32 +0530 Subject: [PATCH] Fixed #8 - Renamed option for eval_expr. - Defined a new option `g:table_mode_map_prefix` set to `t` by default to be used as a prefix for all other table mode commands. - Updated docs to reflect the same. - Updated README. --- README.md | 2 +- doc/table-mode.txt | 91 ++++++++++++++++++++++--------------------- plugin/table-mode.vim | 42 ++++++++------------ 3 files changed, 65 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index 43469af..3235962 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ $ git submodule add git@github.com:dhruvasagar/vim-table-mode.git bundle/table-m formulas on the line separated with a ';' eg) `# tmf: $3=$2*$1;$4=$3/3.14` You can evaluate the formula line using `:TableEvalFormulaLine` or the - mapping `tfe` defined by the option `g:table_mode_expr_calc_map` + mapping `tfe` defined by the option `g:table_mode_eval_expr_map` from anywhere inside the table or while on the formula line. - **Formula Expressions** : diff --git a/doc/table-mode.txt b/doc/table-mode.txt index bfc6a7b..baf41bf 100644 --- a/doc/table-mode.txt +++ b/doc/table-mode.txt @@ -36,7 +36,7 @@ Create Table on the fly: The table mode is disabled by default and you can enter table mode using |table-mode-toggle-map| or you can also enable it permanently - using |g:table-mode-always-active| if you wish. + using |table-mode-always-active| if you wish. Table Mode allows for creation of tables within comments, it looks at the 'commentstring' setting to identify whether the current line is @@ -46,6 +46,14 @@ Tableize content: Table Mode enables conversion of delimited text into tables. Again like table creation, this is also applicable within comments. +Move between cells : + Now you can move between cells using table mode motions + 't[hjkl]' to move left | down | up | right cells respectively. + You can use |table-mode-map-prefix| option to define the prefix + 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 + cell in the current row if one exists. + Manipulation of tables: Tableize provides 3 easy ways to quickly manipulate tables. @@ -126,28 +134,25 @@ Overview: |table-mode-corner| ............. Set corner character. |table-mode-separator| .......... Set separator character. |table-mode-fillchar| ........... Set table fillchar character. + |table-mode-map-prefix| ......... Set prefix for table mode commands. |table-mode-toggle-map| ......... Set table mode toggle mapping. |table-mode-always-active| ...... Set table mode to always enabled. |table-mode-delimiter| .......... Set the delimiter for Tableize. |table-mode-tableize-map| ....... Set mapping for Tableize. |table-mode-tableize-op-map| .... Set mapping for Tableize with input. - |table-mode-align| .............. Set the text alignment for - Tableize. - |table-mode-no-border-padding| .. Set for no border padding. |table-mode-realign-map| ........ Set mapping for table realigning. - |table-mode-motion-prefix| ...... Set prefix for table mode motions. |table-mode-cell-text-object| ... Set mapping for table cell object. |table-mode-delete-row-map| ..... Set mapping for deleting table row. |table-mode-delete-column-map| .. Set mapping for deleting table column. |table-mode-add-formula-map| .... Define a new table formula for the current cell. - |table-mode-expr-calc-map| ...... Evaluate formula line and update + |table-mode-eval-expr-map| ...... Evaluate formula line and update table. -g:table_mode_loaded *table-mode-loaded* +g:loaded_table_mode *table-mode-loaded* Use this option to disable the plugin: > - let g:table_mode_loaded = 1 + let g:loaded_table_mode = 1 < g:table_mode_border *table-mode-border* @@ -171,12 +176,21 @@ g:table_mode_fillchar *table-mode-fillchar* let g:table_mode_fillchar = '-' < +g:table_mode_map_prefix *table-mode-map-prefix* + Use this option to define the table mode mapping prefix that will be + prefixed for all other table mode mappings. > + let g:table_mode_map_prefix = 't' +< + g:table_mode_toggle_map *table-mode-toggle-map* Use this option to define the mapping for toggling the table mode: > - let g:table_mode_toggle_map = 'tm' + let g:table_mode_toggle_map = 'm' < Read |table-mode-mappings-toggle| for more info. + NOTE you will need to use the |table-mode-map-prefix| before this to + get the desired effect. + g:table_mode_always_active *table-mode-always-active* Use this option to permanently enable the table mode: > let g:table_mode_always_active = 0 @@ -197,7 +211,7 @@ g:table_mode_delimiter *table-mode-delimiter* g:table_mode_tableize_map *table-mode-tableize-map* Use this option to define the mapping to invoke |:Tableize| with default delimiter, i.e. |:Tableize| without input. > - let g:table_mode_tableize_map = 'tt' + let g:table_mode_tableize_map = 't' < g:table_mode_tableize_op_map *table-mode-tableize-op-map* @@ -207,37 +221,13 @@ g:table_mode_tableize_op_map *table-mode-tableize-op-map* let g:table_mode_tableize_op_map = 'T' < -g:table_mode_align *table-mode-align* - Use this option to define the format for text alignment to be used for - the tables. Go through |tabular-walkthrough| for details on how to set - the format options for alignment. > - let g:table_mode_align = 'l1' -< - -g:table_mode_no_border_padding *table-mode-no-border-padding* - Use this option to remove the border padding (extra spaces around the - |table-mode-fillchar|). > - let g:table_mode_no_border_padding = 0 -< - NOTE this option changes |table-mode-align| to 'c0', so that - there is no extra padding around the contents. - g:table_mode_realign_map *table-mode-realign-map* Use this option to define the mapping for realigning table columns. This is useful in case you make edits to an existing table. > - let g:table_mode_realign_map = 'tr' + let g:table_mode_realign_map = 'r' < - -g:table_mode_motion_prefix *table-mode-motion-prefix* - Use this option to define the prefix for table mode motion commands. > - let g:table_mode_motion_prefix = 't' -< - You can move to the next / previous row / column using the motion - commands. The motions 'hjkl' follow the prefix are in accordance to - standard vim character motions to make them easier to remember. They - may also be preceeded with a [count]. The 'h', 'l' (left and right - motions) wrap around the table row and move to the previous rows last - column, next rows first column respectively if one exists. + NOTE you will need to use the |table-mode-map-prefix| before this to + get the desired effect. g:table_mode_cell_text_object *table-mode-cell-text-object* Use this option to define the table mode cell text object. > @@ -259,30 +249,43 @@ g:table_mode_cell_text_object *table-mode-cell-text-object* g:table_mode_delete_row_map *table-mode-delete-row-map* Use this option to define the mapping for deletion of the entire table row. You can delete multiple rows by preceeding this with a [count]. > - let g:table_mode_delete_column_map = 'tdd' + let g:table_mode_delete_column_map = 'dd' +< + NOTE you will need to use the |table-mode-map-prefix| before this to + get the desired effect. g:table_mode_delete_column_map *table-mode-delete-column-map* Use this option to define the mapping for deletion of the entire table column. You can delete multiple columns to the right by preceeding this with a [count] > - let g:table_mode_delete_column_map = 'tdc' + let g:table_mode_delete_column_map = 'dc' < + NOTE you will need to use the |table-mode-map-prefix| before this to + get the desired effect. g:table_mode_add_formula_map *table-mode-add-formula-map* Use this option to define the mapping for invoking |TableAddFormula| command. > - let g:table_mode_add_formula_map = 'tfa' + let g:table_mode_add_formula_map = 'fa' < + NOTE you will need to use the |table-mode-map-prefix| before this to + get the desired effect. -g:table_mode_expr_calc_map *table-mode-expr-calc-map* +g:table_mode_eval_expr_map *table-mode-eval-expr-map* Use this option to define the mapping for invoking |TableEvalFormulaLine| command. > - let g:table_mode_expr_calc_map = 'tfe' + let g:table_mode_eval_expr_map = 'fe' < + NOTE you will need to use the |table-mode-map-prefix| before this to + get the desired effect. =============================================================================== MAPPINGS *table-mode-mappings* + *table-mode-mappings-prefix* +t This is a prefix defined by the option |table-mode-map-prefix| + used before all other table mode commands. + *table-mode-mappings-toggle* tm Toggle table mode for the current buffer. You can change this using the |toggle-mode-options-toggle-map| option. @@ -325,7 +328,7 @@ MAPPINGS *table-mode-mappings* tfe Evaluate the formula line which is a commented line right after the table beginning with 'tmf:'. If one exists this would evaluate the formula line and update the table - accordingly. + accordingly. This invokes the |TableEvalFormulaLine| command. =============================================================================== COMMANDS *table-mode-commands* @@ -368,7 +371,7 @@ COMMANDS *table-mode-commands* The above command will Tableize using ';' as the delimiter. NOTE this is optional, by default without the expression it will - tableize the content using |g:table-mode-delimiter| as the delimiter. + tableize the content using |table-mode-delimiter| as the delimiter. *:TableAddFormula* *table-mode-:TableAddFormula* diff --git a/plugin/table-mode.vim b/plugin/table-mode.vim index d44a71e..9cdd22d 100644 --- a/plugin/table-mode.vim +++ b/plugin/table-mode.vim @@ -26,13 +26,6 @@ endif let g:loaded_table_mode = 1 "}}}1 -" " Finish if Tabularize plugin is not available {{{1 -" if !exists(':Tabularize') -" echoerr 'Table Mode depends on Tabularize, ensure that is installed first.' -" finish -" endif -" " }}}1 - " Avoiding side effects {{{1 let s:save_cpo = &cpo set cpo&vim @@ -50,19 +43,18 @@ call s:SetGlobalOptDefault('table_mode_border', 1) call s:SetGlobalOptDefault('table_mode_corner', '+') call s:SetGlobalOptDefault('table_mode_separator', '|') call s:SetGlobalOptDefault('table_mode_fillchar', '-') -call s:SetGlobalOptDefault('table_mode_toggle_map', 'tm') +call s:SetGlobalOptDefault('table_mode_map_prefix', 't') +call s:SetGlobalOptDefault('table_mode_toggle_map', 'm') call s:SetGlobalOptDefault('table_mode_always_active', 0) call s:SetGlobalOptDefault('table_mode_delimiter', ',') -call s:SetGlobalOptDefault('table_mode_tableize_map', 'tt') +call s:SetGlobalOptDefault('table_mode_tableize_map', 't') call s:SetGlobalOptDefault('table_mode_tableize_op_map', 'T') -call s:SetGlobalOptDefault('table_mode_align', 'l1') -call s:SetGlobalOptDefault('table_mode_realign_map', 'tr') -call s:SetGlobalOptDefault('table_mode_motion_prefix', 't') +call s:SetGlobalOptDefault('table_mode_realign_map', 'r') call s:SetGlobalOptDefault('table_mode_cell_text_object', 'tc') -call s:SetGlobalOptDefault('table_mode_delete_row_map', 'tdd') -call s:SetGlobalOptDefault('table_mode_delete_column_map', 'tdc') -call s:SetGlobalOptDefault('table_mode_add_formula_map', 'tfa') -call s:SetGlobalOptDefault('table_mode_expr_calc_map', 'tfe') +call s:SetGlobalOptDefault('table_mode_delete_row_map', 'dd') +call s:SetGlobalOptDefault('table_mode_delete_column_map', 'dc') +call s:SetGlobalOptDefault('table_mode_add_formula_map', 'fa') +call s:SetGlobalOptDefault('table_mode_eval_expr_map', 'fe') "}}}1 function! s:TableMotion() "{{{1 @@ -75,7 +67,7 @@ endfunction " Define Commands & Mappings {{{1 if !g:table_mode_always_active "{{{2 - exec "nnoremap " . g:table_mode_toggle_map . + exec "nnoremap " . g:table_mode_map_prefix . g:table_mode_toggle_map . \ " :call tablemode#TableModeToggle()" command! -nargs=0 TableModeToggle call tablemode#TableModeToggle() command! -nargs=0 TableModeEnable call tablemode#TableModeEnable() @@ -96,25 +88,25 @@ command! -nargs=? -range Tableize ,call tablemode#TableizeRange( " . g:table_mode_tableize_map . +execute "xnoremap " . g:table_mode_map_prefix . g:table_mode_tableize_map . \ " :Tableize" -execute "nnoremap " . g:table_mode_tableize_map . +execute "nnoremap " . g:table_mode_map_prefix . g:table_mode_tableize_map . \ " :Tableize" execute "xnoremap " . g:table_mode_tableize_op_map . \ " :call tablemode#TableizeByDelimiter()" -execute "nnoremap " . g:table_mode_realign_map . +execute "nnoremap " . g:table_mode_map_prefix . g:table_mode_realign_map . \ " :call tablemode#TableRealign('.')" -execute "nnoremap " . g:table_mode_motion_prefix . +execute "nnoremap " . g:table_mode_map_prefix . \ " :call TableMotion()" execute "onoremap " . g:table_mode_cell_text_object . \ " :call tablemode#CellTextObject()" -execute "nnoremap " . g:table_mode_delete_row_map . +execute "nnoremap " . g:table_mode_map_prefix . g:table_mode_delete_row_map . \ " :call tablemode#DeleteRow()" -execute "nnoremap " . g:table_mode_delete_column_map . +execute "nnoremap " . g:table_mode_map_prefix . g:table_mode_delete_column_map . \ " :call tablemode#DeleteColumn()" -execute "nnoremap " . g:table_mode_add_formula_map . +execute "nnoremap " . g:table_mode_map_prefix . g:table_mode_add_formula_map . \ " :TableAddFormula" -execute "nnoremap " . g:table_mode_expr_calc_map . +execute "nnoremap " . g:table_mode_map_prefix . g:table_mode_eval_expr_map . \ " :TableEvalFormulaLine" "}}}1