With VIM, use both snipMate and pydiction together (share the <tab> key?)
Asked Answered
D

3

15

I am trying to use snipMate and pydiction in vim together - however, both use the <tab> key to perform their genius-auto-completion-snippet-rendering-goodness-that-I-so-desire.

When pydiction is installed, snipMate stops working. I assume its because they can't both own the <tab> key. How can I get them to work together?

I wouldn't mind mapping one of them to a different key, but I am not really sure how to do this ... (maybe pydiction to the <ctrl-n> key so it mimics vim's autocomplete?).

Here is the relevant .vimrc:

filetype indent plugin on 

autocmd FileType python set ft=python.django 
autocmd FileType html set ft=html.django_template 

let g:pydiction_location = '~/.vim/ftplugin/pydiction-1.2/complete-dict'
Detainer answered 6/11, 2009 at 12:25 Comment(0)
M
14

Well, this is from the Snipmate help file :)

                                                              *snipMate-remap*
snipMate does not come with a setting to customize the trigger key, but you
can remap it easily in the two lines it's defined in the 'after' directory
under 'plugin/snipMate.vim'. For instance, to change the trigger key
to CTRL-J, just change this: >

 ino <tab> <c-r>=TriggerSnippet()<cr>
 snor <tab> <esc>i<right><c-r>=TriggerSnippet()<cr>

to this: >
 ino <c-j> <c-r>=TriggerSnippet()<cr>
 snor <c-j> <esc>i<right><c-r>=TriggerSnippet()<cr>
Massimiliano answered 6/11, 2009 at 20:20 Comment(3)
Perfect - thanks! Perhaps in all my searching I should have looked more closely at the help docs. Heh.Detainer
No longer true, now the documentation specifies that it can be remapped with imap <C-J> <Plug>snipMateNextOrTrigger and smap <C-J> <Plug>snipMateNextOrTriggerContradiction
+1 @Contradiction See my dotfiles commit with the remaps. github.com/simeonwillbanks/dotfiles/commit/…Mcgregor
J
6

Alternatively, you can edit ~/.vim/after/ftplugin/python_pydiction.vim and change Tab to something else:

" Make the Tab key do python code completion:
inoremap <silent> <buffer> <Tab> 
         \<C-R>=<SID>SetVals()<CR>
         \<C-R>=<SID>TabComplete('down')<CR>
         \<C-R>=<SID>RestoreVals()<CR>

" Make Shift+Tab do python code completion in the reverse direction:
inoremap <silent> <buffer> <S-Tab> 
         \<C-R>=<SID>SetVals()<CR>
         \<C-R>=<SID>TabComplete('up')<CR>
         \<C-R>=<SID>RestoreVals()<CR>
Junia answered 31/3, 2010 at 8:38 Comment(0)
T
4

I believe the way to change the trigger key may have changed since the answer by the_karel was given in 2009 but it is found in the same directory, namely 'after/plugin/snipMate.vim'. I found it in the help file too:

 *snipMate-trigger*
snipMate comes with a setting to configure the key that is used to trigger
snipMate. To configure the key set g:snips_trigger_key to something other than
<tab>,e.g. <c-space> use:

 let g:snips_trigger_key='<c-space>'
Twopiece answered 29/10, 2012 at 0:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.