2

Vimwiki table default mappings include <tab> for moving to the next table column in insert mode. Also UltiSnips default mappings include <tab> for expanding snippets in insert mode. Here is the result for :verbose imap <tab>

i  <Tab>       *@vimwiki#tbl#kbd_tab()
        Last set from ~/.vim/plugged/vimwiki/ftplugin/vimwiki.vim line 543
i  <Tab>       * <C-R>=UltiSnips#ExpandSnippet()<CR>
        Last set from ~/.vim/plugged/ultisnips/autoload/UltiSnips/map_keys.vim line 61

When I intend to use a snippet inside a vimwiki table, <tab> doesn't work - it just follows the vimwiki mapping and takes cursor to the next column. I would like to have <tab> work for both, i.e., if Ultisnips is not triggering results then use Vimwiki, otherwise use UltiSnips. I had mentioned this issue at vimwiki repo on github and was suggested to use a conditional.

I don't really know how to add conditionals for two different plugin mappings, hence asking for help. How do I achieve this?


P.S. There are a few "solutions" to this problem, for instance, as suggested here, one can add

let g:vimwiki_table_mappins = 0

to their .vimrc and then use a different mapping for vimwiki#tbl#kbd_tab(). There are other solutions in that thread as well.

But the reason I am wanting to have conditionals is that it let's me keep same old mappings and also according to vimwiki helpfile, g:vimwiki_table_mappings option will be fully removed at a later point. Then the above wouldn't work. It also seems like a general problem to me to have the same keybinding for different plugin mappings using conditionals.


I would thankful for any help on this, even for a sketch of how to do it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.