dhruvasagar / vim-table-mode

VIM Table Mode for instant table creation.
2.1k stars 97 forks source link

Several mappings in place even when not in vim-table-mode #176

Closed lsimmons2 closed 4 years ago

lsimmons2 commented 4 years ago

Hi, thanks for the great plugin! When I start up vim, before calling :TableModeToggle (vim-table-mode not enabled) I have some vim-table-mode mappings already set.

:map shows:

x  <Space>T      <Plug>(table-mode-tableize-delimiter)
x  <Space>tt     <Plug>(table-mode-tableize)
n  <Space>tt     <Plug>(table-mode-tableize)

Are these mappings supposed to be here even when vim-table-mode is not enabled? Can I disable these by default?

This is with Vim version 8.0.1453, installed with Vim-Plug.

dhruvasagar commented 4 years ago

This is by design, since the actions Tableize is used to convert existing content into a table, these are relevant even when table mode is not enabled. There are configurations provided that allow to change these mappings. I would suggest you read more in the :h table-mode

lsimmons2 commented 4 years ago

@dhruvasagar thanks but I tried using let g:table_mode_disable_mappings = 1 and those three mappings were still there. Tried deleting plugin and reinstalling with that variable set with the same result. What's the right way to get rid of those mappings?

dhruvasagar commented 4 years ago

@lsimmons2 Like I said, these mappings aren't related to table-mode mappings and are available globally because they're relevant even when no table exists.

Quoting from help :

g:table_mode_tableize_map                              *table-mode-tableize-map*
        Set this to configure the mapping for converting the visual selection
        to a table. >
                let g:table_mode_tableize_map = '<Leader>tt'
>
g:table_mode_tableize_d_map                          *table-mode-tableize-d-map*
        Set this to configure the mapping for converting the visual selection
        to a table, asking the user for a delimiter. >
                let g:table_mode_tableize_d_map = '<Leader>T'
>
dhruvasagar commented 4 years ago

@lsimmons2 You should be able to disable these mappings adding the following configuration :

nmap <Plug>(table-mode-tableize) <Nop>
nmap <Plug>(table-mode-tableize-delimiter) <Nop>

If however you wish to change the mappings to something different, you can use the provided configurations

lsimmons2 commented 4 years ago

Trying that and those mappings still show up in :map.

dhruvasagar commented 4 years ago

@lsimmons2 Thanks, turns out I misunderstood how <Nop> is supposed to work. I have pushed a new configuration g:table_mode_disable_tableize_mappings which you can set to 1(Default is 0) to disable these mappings.

lsimmons2 commented 4 years ago

@dhruvasagar thanks for your help. I just updated the plugin and when setting let g:table_mode_disable_tableize_mappings=1 those mappings are gone, but a new one shows up now: n <Space>tm * :<C-U>call tablemode#Toggle()<CR>

dhruvasagar commented 4 years ago

@lsimmons2 Yes that is used to enable table mode, if you want to disable that too, you might as well uninstall the plugin

lsimmons2 commented 4 years ago

@dhruvasagar ok and it couldn't be set up so that the user could choose to disable this mapping or just have it be an unmapped <Plug> command by default? I'd imagine most users of this plugin are experienced Vim users who would want to set up their own mappings anyway and wouldn't like not being able to remove a default mapping since it feels like it "pollutes" their :map space.

Personally, I have let mapleader=" " and nnoremap <leader>t :tabnew<CR>, so because of n <Space>tm * :<C-U>call tablemode#Toggle()<CR> I have to wait for the timeout before a new tab opens. It gets frustrating :)

dhruvasagar commented 4 years ago

@lsimmons2 Most mappings are available as plug mappings and the defaults are applied only if the user does not set these themselves. There are also convenience configurations available that can also be used to override these mappings in different ways.

Some configurations that you could leverage would be g:table_mode_map_prefix, this is used as a prefix for all table wide mappings, if you changed this to something like <Leader>r the table mode toggle mapping would become <Leader>rm. You can also change the non-prefix part of that mapping by setting g:table_mode_toggle_map.

All of this is described in detail in the help documentation.

kurko commented 4 years ago

I set let g:table_mode_map_prefix = "<Leader>xxxxxxxxxxxxxxxxxx" because I really don't want plugins taking over the mappings that I have composed over the years.

let g:table_mode_disable_mappings = 1
let g:table_mode_disable_tableize_mappings = 1
let g:table_mode_map_prefix = "<Leader>xxxxxxxxxxxxxxxxxx"

Instead, I just set an autocmd for *.md for automatically resizing the tables.