0

I want to assign value based on filetype.

I am using UltiSnips plugin and want to have one set of bindings for one filetype and another set for everything else.

Something like

if &ft='vimwiki'
    let g:UltiSnipsExpandTrigger="<tab>"
else
    let g:UltiSnipsExpandTrigger="<c-tab>"
endif
1
1

I would try something like the following. In my vimrc (or a plugin file, :help load-plugins; I often use ~/.vim/after/plugin/config/<pluginname>.vim), I would define

let g:UltiSnipsExpandTrigger="<c-tab>"`

Then, in an ftplugin (:help ftplugins, I would use ~/.vim/after/ftplugin/vimwiki.vim), make the change:

let b:UltiSnipsExpandTrigger="<tab>"

This type of thing normally works well for dynamic configuration. If UltiSnips creates a mapping when it loads based on this variable (as I suspect it does), it may not be "dynamic"—that is, changing the variable may have no effect. In that case, you will need to find a way to get UltiSnips to change its mappings and such dynamically. Possibly the right combination of unmap/unlet and runtime are enough, but otherwise you might have to add some code to UltiSnips to support a buffer-local trigger and such.

Not the answer you're looking for? Browse other questions tagged or ask your own question.