2009-11-06 9 views
16

Sto cercando di usare snipMate e pydiction in vim insieme - tuttavia, entrambi utilizzano la chiave <tab> di svolgere il loro genio-auto-completamento-frammento di rendering -goodness-che-io-so-desiderio.con vim, utilizzare sia snipMate e pydiction insieme (condividono la chiave <tab>?)

Quando pydiction è installato, snipMate smette di funzionare. Presumo che sia perché non possono entrambi possedere la chiave <tab>. Come posso convincerli a lavorare insieme?

Non mi dispiacerebbe mappare uno di essi a una chiave diversa, ma non sono davvero sicuro di come farlo ... (forse pydiction per la chiave <ctrl-n> così imita il completamento automatico di vim?).

Ecco la .vimrc rilevante:

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' 

risposta

15

Bene, questo è dal file di aiuto Snipmate :)

               *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> 
+0

Perfetto - grazie! Forse in tutte le mie ricerche avrei dovuto esaminare più da vicino i documenti di aiuto. Eh. – thornomad

+3

Non è più vero, ora la documentazione specifica che può essere rimappata con 'imap snipMateNextOrTrigger' e' smap snipMateNextOrTrigger' – TKrugg

+1

+1 @TKrugg Vedere i miei dotfile eseguire il commit con i riassunti. https://github.com/simeonwillbanks/dotfiles/commit/660b0505c82157656e15d47cd43108d2d39409db – simeonwillbanks

7

In alternativa, è possibile modificare ~/.vim/after/ftplugin/python_pydiction.vim e cambiare Tab a qualcos'altro:

" 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> 
+0

+1: questo funziona per me. –

4

Credo che w a cambiare il tasto di attivazione potrebbe essere cambiato da quando la risposta di the_karel è stata data nel 2009 ma si trova nella stessa directory, ovvero 'after/plugin/snipMate.vim'. L'ho trovato anche nel file della guida:

*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>' 
Problemi correlati